Skip to content

Instantly share code, notes, and snippets.

@bchase
Last active October 6, 2018 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bchase/312d8ae5b86a54d526e2fa305fd46cdc to your computer and use it in GitHub Desktop.
Save bchase/312d8ae5b86a54d526e2fa305fd46cdc to your computer and use it in GitHub Desktop.
// what we get
new Date('2018-10-01')
// Sun Sep 30 2018 20:00:00 GMT-0400 (Eastern Daylight Time)
// what we want
new Date('2018-10-01 GMT-0400')
// Mon Oct 01 2018 00:00:00 GMT-0400 (Eastern Daylight Time)
// getting it :)
var tz = new Date().toString().match(/[^\s]+[-+]\d{4}/)[0]
new Date('2018-10-01' + ' ' + tz)
// Mon Oct 01 2018 00:00:00 GMT-0400 (Eastern Daylight Time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment