The Date object doesn't overload +
, so new Date() + n
simply concatenates both operands as strings.
Eg:
new Date() + (-1) * 60 * 1000
is equivalent to
String(new Date()) + String((-1) * 60 * 100)
and yields (depending on locale)
Fri Nov 11 2016 09:05:43 GMT+0100-6000
The second example yields a value because the "-6000" looks like a timezone modifier that subtracts sixty hours, even though there is already one. This is a parsing quirk of Chrome - Firefox will reject it, but Chrome will accept the "-6000" and yield a date sixty hours in the future.
This only works if the appended string is exactly four digits (the first two digits for the hours, two for the minutes), and has either a + or a - in front of it. That's why it works if you add "-6000", but not "-60000". It wouldn't work with positive numbers either, unless you added the "+" character manually.
I suspect that what you actually want is
Date.now() - 60 * 1000
Date.now()
instead ofnew Date()
in there.new Date().toString()
returns a string ,then when you do+ (-1)
it concatenates instead of adding. So it returns something like "Fri Nov 11 2016 00:02:59 GMT-0800 (Pacific Standard Time)-60000"