I've been working on a time app for JS and I was wondering, how could I change the time zone. See, I live in the eastern time zone of North America, and i don't like converting it to the International Timezone. So here is my Code.
<button type="button"
onclick="document.getElementById('time').innerHTML = Date()">
Click me to display Date and Time.</button>
<p id="time"></p>
When I click the button, I get,
Wed Dec 30 2015 13:40:25 GMT+0000 (UTC)
But I want it to be:
Wed Dec 30 2015 8:40:25 (EST)
Date.prototype.toString
is supposed to give you a string in your local time (as configured on your client).
When you click Run code snippet
this should show an alert dialog with your local time string (toString
is implicitly called, like in your example);
alert(new Date());
If it does give you the expected result then either you client timezone is not configured correctly or the browser you are using is bugged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With