SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    Pandora Tipem's Avatar
    Join Date
    Feb 2006
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    'Changing' The Time Entered Into Database

    Hello,

    My server is the in the Eastern (USA) timezone, so when things are entered into the database (e.g., mysql_query("insert into myTbl (time_entered) VALUES ('".time()."')")), it obvious enters it in as the EST timezone. Would '".time()-10800."' (10800 seconds = 3 hours) change it to the Pacific TZ, because they are 3 hours behind EST timezone? Does it work this way, or is there any other easier way to do this?
    Tipem no fancy sig, yup
    Need Neopets Help? Try Neopets
    fun adoptable eggs

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure, that would work. Alternatively, you could correct for timezone difference at runtime, when the information i sent to the browser.
    Sincerely,
    Joe Belmaati
    Copenhagen Denmark

  3. #3
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are going to have different users wanting to see time in their own time zone I'd store the times in the DB as GMT 0, and then perform the offsets at display.

    If you want all the times to be set to your time zone then I'd translate them at insertion time.
    Also - I'd store your time zone offset (the 10800 seconds) in a central include somewhere, because you don't know when the time on the server (shared I assume) might change.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •