crazy4groovy
1/23/2018 - 4:22 PM

Get the same date string from a Date object, no matter the timezone of the server.

Get the same date string from a Date object, no matter the timezone of the server.

function tzDate(utcPrefix = 'Sat, 01 Jan 2011 12:00:00') {
  let tz = new Date().toUTCString().split(' ')
  tz = tz[tz.length - 1] // local TZ
  return new Date(`${utcPrefix} ${tz}`)
}