Results 1 to 3 of 3

Thread: Format time stamp to Local time zone

  1. #1
    Join Date
    Jul 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Format time stamp to Local time zone

    Can javascript be used to turn this time stamp {ts '2007-09-17 21:54:59'}

    into the correct time for the "clients" time zone?


    Thanks for your help!

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    JavaScript does support the creation of a date object using a full date/time string as its parameter. You can then convert that into the local format in which date/time is displayed for that user. So something like:

    Code:
    <script type="text/javascript">
    
    var mydate=new Date("September 17, 2007 21:54:59")
    alert(mydate.toLocaleString())
    
    </script>
    That's different than adjusting the timestamp time (server time I assume) to the local time of the user though.

  3. #3
    Join Date
    Jul 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Can javascript check to see what time zone or what the "time zone offset" is from "GMT" from the users browser?

    If so, then I could store that as a cookie and then call on it later to adjust the time and date as needed.

    Thanks again!

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
  •