locked
Ensure date handling in UTC format? RRS feed

  • Question

  • User-901247704 posted

    Hi there,

    I have a task where I have to ensure all date handling is in UTC format and am wondering how to go about it? Any good articles etc .. ?

     We are using MySQL databases and have a couple around the world.

     Would you look at the IP address of the user to see what country they are in and then save and display the date to them depending on that. So for example if person 1 saves something at 8pm in Australia it gets saved to the database in UTC format then person 2 checks the same data in the UK he would see it not as 9pm but as 11am (or whatever)? Is using the IP address reliable?

    Is that basically how it works? What about culture info etc?

     Thanks a lot
     

    Wednesday, August 29, 2007 9:31 PM

Answers

All replies

  • User399238829 posted

    This is a good article about UTC: http://aspnet.4guysfromrolla.com/articles/081507-1.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 29, 2007 9:55 PM
  • User-901247704 posted

    Thanks for the article,

     I read it all. It says in the conclusion that storing in UTC fomat is one step in the right direction because of time difference and day light saving confusions.

     

    So does anyone know if it's more complicated then just saving into the database using DataTime.UtcNow() and retrieving from the database using ValueFromDatabase.ToLocalTime();?

    Is it as easy as that? When you save to the database using UtcNow() does it take day light saving times into account? or would I have to do some sort of If statement lie:

    If dayLightSaving Then UtcNow()+1

    Else UtcNow()

    Wednesday, August 29, 2007 11:01 PM