date format yyyy-MM-ddTHH:mm:ssZ

430
Views
1
Answers

Hi,
I need to convert a datetime into the format date format

 yyyy-MM-ddTHH:mm:ssZ

Is that UTC? How do we convert into this format in .Net?

edit | flag
William Patrick
Asked on: Jan 06, 2012 at 2:14AM

1 Answers

93
4
93

Use the UTCNow

Console.WriteLine(DateTime.UtcNow.ToString("s") + "Z");

The output will be

2011-01-06T15:50:55Z

The 'Z' here denotes the zone designator for the zero UTC offset. "15:50 UTC" is therefore represented as "15:50Z" or "15:50Z". Similarly "15:50:45 UTC" would be "15:50:45Z" or "155045Z".
If the time is in UTC, add a 'Z' directly after the time without a space.

edit | flag
Gokul A
Answered on: Jan 06, 2012 at 2:23AM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags