0

For example if you receive a timestamp in Javascript:

1433454951000

How would you create a function to convert the timestamp into UTC like:

2015/6/4 GMT+7

TheRob
  • 133
  • 2
  • 10
  • http://stackoverflow.com/questions/10087819/convert-date-to-another-timezone-in-javascript – Pardeep Dhingra Jun 04 '15 at 16:22
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date <- in the documentation, value can be _Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC (Unix Epoch)._ , like your seems to be. After creating the date object you can really do everything you want with such, including printing that as a timestamp into UTC, perhaps you can even think about a DateTime object... And.. this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString – briosheje Jun 04 '15 at 16:23

1 Answers1

0
var d1 = new Date("UNIX TIME STAMP HERE");
d1.toUTCString()

Originally asked here: How do I get a UTC Timestamp in JavaScript?

Community
  • 1
  • 1
J0N3X
  • 228
  • 2
  • 14