以这种格式显示当前时间:HH:mm:ss
我在以这种格式显示时间时遇到一些问题:HH:mm:ss。 无论我尝试什么,我都不会以这种格式得到它。
我想要在荷兰文化中度过一段时间,即“nl-NL”。
这是我(虽然我忘了数)第 1000 次尝试之一:
CultureInfo ci = new CultureInfo("nl-NL");
string s = DateTime.Now.TimeOfDay.ToString("HH:mm:ss", ci);
我做错了什么?
I'm having some trouble displaying the time in this format: HH:mm:ss.
No matter what i try, i never get it in that format.
I want the time in the culture of the Netherlands which is "nl-NL".
This was one of my (although i forgot to keep the count) 1000th try:
CultureInfo ci = new CultureInfo("nl-NL");
string s = DateTime.Now.TimeOfDay.ToString("HH:mm:ss", ci);
What am i doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要使用 TimeZoneInfo 类,以下是显示当前时间的方法东部标准时间时区,格式为HH:mm:ss:
要查找所有可用的时区,您可以使用
从上面的返回值中查看,您需要的时区的Id(我假设是阿姆斯特丹)称为W欧洲标准时间:
You need to use the TimeZoneInfo class, here's how to show the current time in the Eastern Standard Time time zone in HH:mm:ss format:
To find all the timezones available, you can use
Looking through the returned value from the above, the Id for the time zone you need (Amsterdam I assume) is called W. Europe Standard Time:
TimeOfDay是一个TimeSpan,它只有一个不带参数的ToString()。
使用 Darin 的解决方案 或来自 TimeSpan.ToString() 的 MSDN 文档
TimeOfDay is a TimeSpan, which has only one ToString() without parameters.
Use Darin's solution or a sample from MSDN documentation for TimeSpan.ToString()