Hey,
I have a Date()
object that contains a UTC date, which I need converted to the users local timezone. Does anybody know how I could do this? :-)
Thanks in advanced!
Hey,
I have a Date()
object that contains a UTC date, which I need converted to the users local timezone. Does anybody know how I could do this? :-)
Thanks in advanced!
You could use Date.getTimezoneOffset() that returns the time difference between Greenwich Mean Time (GMT) and local time, in minutes.
A sample from W3 Schools
<script type="text/javascript">
var d = new Date()
var gmtHours = -d.getTimezoneOffset()/60;
document.write("The local time zone is: GMT " + gmtHours);
</script>
I usually create a new Date
object and use the Date.setUTC*
functions to copy the date information.