6

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) 
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
Patton Pierce
  • 317
  • 1
  • 2
  • 14

1 Answers1

1

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.

Xotic750
  • 22,914
  • 8
  • 57
  • 79