Last active
August 29, 2015 14:24
-
-
Save swanwish/d4e537fcaaed0ccbaa31 to your computer and use it in GitHub Desktop.
Safari new Date('2015-07-06') invalid date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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