2

I'm trying to convert the UTC Time on Server that located overseas to local time e.g. Australia. Could anyone please help me to achieve this

Thanks.

1
  • 4
    Sure! What have you tried yourself, so far? What trouble are you running into? Any relevant code? Commented Jun 16, 2011 at 10:46

3 Answers 3

10
DateTime.ParseExact(s, "yyyyMMdd").ToLocalTime()

The MM needs to be capital, because mm means minutes, not months.

Sign up to request clarification or add additional context in comments.

Comments

2

Use DateTime.Parse().

If the input string does not have the timezone offset included (for example, 03/01/2009 05:42:00 -5:00, Sat, 01 Nov 2008 19:35:00 GMT or 2008-11-01T19:35:00.0000000-07:00), then ensure that the DateTme.Kind is "Utc", then call DateTime.ToLocal() to convert it to the local time zone.

Comments

0

Would you not be better using

DateTime.TryParse(String DateString, out DateTime result)

Then should anything be wrong you won't get the exception thrown - you can check the values instead (or use a IF)!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.