PDA

View Full Version : Format time stamp to Local time zone



unitedlocalbands
09-18-2007, 01:56 AM
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!

ddadmin
09-18-2007, 04:01 AM
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:


<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.

unitedlocalbands
09-18-2007, 06:00 PM
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!