如何在 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
How to display millisecond from Date and time in 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")
.ToString("yyyy-MM-dd").ToString("hh':'mm':'ss")
.ToString("yyyy-MM-dd").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")

