Skip to content

Instantly share code, notes, and snippets.

@swanwish
Last active August 29, 2015 14:24
Show Gist options
  • Save swanwish/d4e537fcaaed0ccbaa31 to your computer and use it in GitHub Desktop.
Save swanwish/d4e537fcaaed0ccbaa31 to your computer and use it in GitHub Desktop.
Safari new Date('2015-07-06') invalid date
// Use moment to parse date to handle different browser
var startDate = moment('2015-07-06 08:00', 'YYYY-MM-DD HH:mm').toDate();
var timestamp = startDate.getTime();
console.log(timestamp);
// Output
// 1436140800000
// Get Unix timestamp
var unixTimestamp = moment('2015-07-06 08:00', 'YYYY-MM-DD HH:mm').unix()
console.log(unixTimestamp);
// Output
// 1436140800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment