Rwolffs
Rwolffs

Reputation: 11

"DateTime.Now.ToShortTimeString" displays wrong time of day (offset by some hours)

So i tried using the

 DateTime.Now.ToShortTimeString();

method but it gives me the wrong time for example my current time is 9:09 PM but when i run the code it gives me 3:09 AM so pls help me.

Upvotes: 0

Views: 626

Answers (1)

Cristi Stoicescu
Cristi Stoicescu

Reputation: 109

Well , you could look into the TimeZoneInfo class. It can convert any time to utc time , then into the tomezone you want. ( see the methods ConvertTimeToUtc and ConvertTimeFromUtc ) The advantage here is that it can be run on any 2 timezones

Upvotes: 1

Related Questions