windows 如何在 vb.net 中格式化日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3510725/
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 format a date in vb.net
提问by Etienne
I want to display my date like so in VB.NET
我想在 VB.NET 中像这样显示我的日期
2008/01/22 14:23:15
2008/01/22 14:23:15
How is this done in code?
这是如何在代码中完成的?
This does not give me enough: lblDate.Text = Today.Date
这还不够: lblDate.Text = Today.Date
回答by Binary Worrier
Try
尝试
lblDate.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
回答by Dan Tao
This should display the way you want:
这应该以您想要的方式显示:
Dim formattedDate As String = Date.Today.ToString("yyyy/MM/dd HH:mm:ss")
And see Custom DateTime Format Stringsfor a complete reference.
并参阅自定义日期时间格式字符串以获取完整参考。
回答by Amit
Please try : Date.Now
请尝试:Date.Now