如何在 vb.net 中显示日期和时间的毫秒数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40671992/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 20:07:48  来源:igfitidea点击:

How to display millisecond from Date and time in vb.net

vb.net

提问by Anuj Masand

I wish to format my date (22/03/2016 23:59:59) to string with milliseconds.

我希望将我的日期 (22/03/2016 23:59:59) 格式化为以毫秒为单位的字符串。

dr.GetDateTime(1).ToString("yyyy-MM-dd hh:mm:ss")

dr.GetDateTime(1).ToString("yyyy-MM-dd hh:mm:ss")

  1. .ToString("yyyy-MM-dd")
  2. .ToString("hh':'mm':'ss")
  1. .ToString("yyyy-MM-dd")
  2. .ToString("hh':'mm':'ss")

回答by Martin Verjans

If you google DateTime.ToString(), you end up with MSDN documentationexplaining this function.

如果你用 google DateTime.ToString(),你最终会得到解释这个函数的MSDN 文档

Then you can find a link to Custom Date and Time Format, which explains that to display milliseconds, you must do this :

然后你可以找到一个指向Custom Date and Time Format的链接,它解释了要显示毫秒,你必须这样做:

dr.GetDateTime(1).ToString("yyyy-MM-dd hh:mm:ss fff")