Avatar of Asim Nazir
Asim NazirFlag for Pakistan

asked on 

Zulu date and time format

Hi,

I have a DateTime stored in my DataBase. DateTime can be in UTC or GMT format.
What I want is to display it in zulu format.

What to do?

Thanks in anticipation.
.NET ProgrammingC#

Avatar of undefined
Last Comment
Asim Nazir
Avatar of sanjithml
sanjithml
Flag of India image

try this

Code Example:

// This is the format with 'zzzzz' representing local time offset
const string format = "ddd MMM dd HH:mm:ss zzzzz yyyy";

// create a UTC time
const string expected = "Fri Dec 19 17:24:18 +0000 2008";
var time = new DateTime(2008, 12, 19, 17, 24, 18, 0, DateTimeKind.Utc);

// If you're using a debugger this will rightfully throw an exception
// with .NET 3.5 SP1 because 'z' is for local time only; however, the exception
// asks me to use the 'Z' specifier for UTC times, but it doesn't exist, so it
// just spits out 'Z' as a literal.
var actual = time.ToString(format, CultureInfo.InvariantCulture);

Assert.AreEqual(expected, actual);
SOLUTION
Avatar of oxyoo
oxyoo
Flag of Sweden image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Asim Nazir
Asim Nazir
Flag of Pakistan image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Imran Javed Zia
Hi,
According to my info Zulu is synonym of UTC and it is generally in and it will show current date and time as Tuesday 17 May 2011 13:46:53
 
string s = DateTime.Now.ToString("MMMM dd yyyy HH:mm:ss");

Thanks
Avatar of Asim Nazir
Asim Nazir
Flag of Pakistan image

ASKER

None of the solutions proposed by other experts worked for me. I posted my solution just for reference to others.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo