自定义日期和时间格式字符串
1 |
DateTime thisDate1 = new DateTime(2011, 6, 10); |
02 |
Console.WriteLine("Today is " + thisDate1.ToString("MMMM dd, yyyy") + "."); |
03 |
|
04 |
DateTimeOffset thisDate2 = new DateTimeOffset(2011, 6, 10, 15, 24, 16, |
05 |
TimeSpan.Zero); |
06 |
Console.WriteLine("The current date and time: {0:MM/dd/yy H:mm:ss zzz}", |
07 |
thisDate2); |
08 |
// The example displays the following output: |
09 |
// Today is June 10, 2011. |
10 |
// The current date and time: 06/10/11 15:24:16 +00:00 |
转载:http://dev.mjxy.cn/a-Custom-date-and-time-format-string.aspx


浙公网安备 33010602011771号