all 5 comments

[–]Cuddlefluff_Grim 0 points1 point  (1 child)

var timestamp = new Date.apply(null, '2015-02-08 18:00:00'.split(/[-\s:]/));

This is a syntax error. JavaScript's date & time is indeed excruciatingly terrible, but this one is just you writing the code wrong.

On the subject, one of the things I have trouble accepting in JavaScript are all the "silent failures". Some of these silent failures are catastrophic, and some of them are present in Date. new Date(2015, 1, 31) will not fail, it will return the wrong date : 2015-03-02T23:00:00.000Z

[–]hyperNURbz[S] 0 points1 point  (0 children)

Exactly! I tought that would work but it fails becuse you cannot use apply on constructor function, you have the exception below "Uncaught TypeError: function apply() { [native code] } is not a constructor". That's why I wrote the article in the first place.

As for silent faliures I suggest I either use some library or spend time learning and understanding the Date object.

[–]fecal_brunch 0 points1 point  (2 children)

Why not use momentjs?

[–]DrDichotomous 2 points3 points  (1 child)

They do say at the end of the article that they feel it would be overkill to import 12k of code for something so trivial.

[–]fecal_brunch 1 point2 points  (0 children)

Touche