java yyyy-mm-ddthh:mm:ssz,日期格式YYYY-MM-DDTHH:MM:SSZ
I assume this should be pretty simple, but could not get it :(.
In this format Z is time zone.
T is long time pattern
How could I get a date in this format except by using
DateTime dt = DateTime.Now;
Console.WriteLine(dt.ToString("yyyy-MM-ddTHH:mm:ssZ"));
in C#
解决方案
Using UTC
Console.WriteLine(DateTime.UtcNow.ToString("s") + "Z");
2009-11-13T10:39:35Z
The Z is there because
If the time is in UTC, add a Z
directly after the time without a
space. Z is the zone designator for
the zero UTC offset. "09:30 UTC" is
therefore represented as "09:30Z" or
"0930Z". "14:45:15 UTC" would be
"14:45:15Z" or "144515Z".
If you want to include an offset
I assume this should be pretty simple, but could not get it :(. In this format Z is time zone. T is long time pattern How could I get a date in this format except by using DateTime dt = DateTime.Now; Console.WriteLine(dt.ToString("yyyy-MM-ddTHH:mm:ssZ")); in C# 解决方案 Using UTC Console.WriteLine(DateTime.UtcNow.ToString("s") + "Z"); 2009-11-13T10:39:35Z The Z is there because If the time is in UTC, add a Z directly after the time without a space. Z is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z". If you want to include an offset