0

I have a UTC timestamp in this format: 2016-04-18 14:38:12

I am using getTimezoneOffset();

i think the number from getTimezoneoffset(); is minutes. how can i change the original UTC time into the current time with getTimezoneOffset? possibly just adding and subtracting?

johnny
  • 1
  • I would recommend using MomentJs for time related things. http://momentjs.com/ – Rastalamm Jun 29 '16 at 18:36
  • @Rastalamm i want to use vanilla js – johnny Jun 29 '16 at 18:37
  • 2
    see http://stackoverflow.com/questions/13622142/javascript-to-convert-utc-to-local-time – theCaveat Jun 29 '16 at 18:38
  • @theCaveat it says toString, what does that do in terms of date? does it convert the date object to local time date? – johnny Jun 29 '16 at 18:46
  • @johnny [Date.toString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString) returns the string representation of the date. If you want a more reliable way that works the same across all browsers, you might want to try [this answer](http://stackoverflow.com/a/13622393/2905091) – theCaveat Jun 29 '16 at 20:01
  • @johnny - vanilla js doesn't account for all kinds of time anomalies (especially when dealing with timezones). Not sure what this project is for etc but momentjs is super easy to accomplish what you're doing.. ex: moment().add(4, "hours"); – Rastalamm Jun 30 '16 at 01:11

0 Answers0