How to covert UTC time into local time RRS feed

  • Question

  • Dear Friends,

    Wishing you all for happy and prosperous new year.

    I am not able to convert UTC time into local time.The UTC time is 1261912292000 and equivalent local time is 01/05/10 17:48:31. Can any one tell me how to covert UTC time to local time is above format.

    Tuesday, January 5, 2010 12:22 PM


  • Hi there.

    To me it seems that you are talking about Unix time stamps, since UTC is the complete date and time +  time zone.

    If it's Unix time we are talking about, you can convert back and forth using these methods:

    private DateTime ConvertToDateTime(double unixTime)
      return new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(unixTime);
    private double ConvertToUnixTime(DateTime dt)
      return (dt - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;

    Hope this helps

    My blog: InsomniacGeek.com
    • Marked as answer by Ravish_K Monday, January 11, 2010 12:31 PM
    Tuesday, January 5, 2010 1:42 PM