当前时间+ 24小时 [英] Current Time + 24 Hours
本文介绍了当前时间+ 24小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
如何格式化当前+24小时的日期和时间,如下所示:
2010年5月24日,星期一21:23:04 GMT
谢谢
Hi guys
How can I format the current+24 hour Date and Time to look like this:
Mon, 24-May-2010 21:23:04 GMT
Thanks
推荐答案
如果您给我们用什么语言,这会有所帮助.日期时间的to string方法采用格式字符串. http://www.codeproject.com/KB/cs/String2DateTime.aspx
It would help if you old us what language. The to string method on the date time takes format strings. http://www.codeproject.com/KB/cs/String2DateTime.aspx
String.Format("{0:r}",DateTime.Now);
(DateTime.Now).ToString("{0:r}");
String.Format("{0:r}", DateTime.Now);
(DateTime.Now).ToString("{0:r}");
请参见 ^ ]中列出了可以使用的格式.
以下是一些选项:
see here[^] for a list of formats that you can use.
here are some options:
DateTime.UtcNow.ToString("r")
'equals Mon, 24 May 2010 22:56:46 GMT
'If you want to add the hyphens try
DateTime.UtcNow.ToString("ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'")
'equals Mon, 24-May-2010 22:56:46 GMT
您绝对想要UtcNow,因为这样会将它转换为协调的通用时间,即随意使用,当几分之一秒不重要时,格林威治标准时间(GMT)可以认为等同于UTC或UT1",来自http://en.wikipedia.org/wiki/Coordinated_Universal_Time [
you definitely want UtcNow though because that will convert it to coordinated universal time which "in casual use, when fractions of a second are not important, Greenwich Mean Time (GMT) can be considered equivalent to UTC or UT1" from http://en.wikipedia.org/wiki/Coordinated_Universal_Time[^]
这篇关于当前时间+ 24小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文