Search code examples
c#datetimedatetime-format

how to convert datetime value to zulu time zone format in c#?


the current value i have when fetched from database is

2018-02-13T12:36:00 ;

//but i need it to be convert like below (where z and the end denotes zulu timezone)

2018-02-13T12:36:00Z ; 

Note :i am storing the value in a datetime variable and i dont want this in a string format.i tried converting it to string and append Z to it but it
changes the format like this which is not expected result.Any help is appreciated

2/13/2018 12:36: PMZ

Solution

  • The Answer is

    .ToUniversalTime() 
    

    it converts the date time to Zulu time zone format as it is a part of UTC Time Zone(Zulu time zone is -UTC +0 )

    The example mentioned in This MSDN article did not mention about 'Z'(Zulu time zone indication) but this method does convert to Zulu time zone.