Last active
December 27, 2015 05:48
-
-
Save amirnissim/7276380 to your computer and use it in GitHub Desktop.
JS dates gotcha when using ternary comparison
This file contains 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
now = new Date() | |
// Sat Nov 02 2013 08:56:45 GMT+0200 (IST) | |
start = new Date() | |
start.setMonth(start.getMonth()-1) | |
start | |
// Wed Oct 02 2013 08:57:26 GMT+0300 (IDT) | |
end = new Date() | |
end.setDate(end.getDate()-1) | |
// Fri Nov 01 2013 08:57:30 GMT+0200 (IST) | |
start < now | |
// true | |
now < end | |
// false | |
start < now < end | |
// true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment