It’s like they say – there are two difficult things in Computer Science: naming things, invaliding cache, and off-by-one errors. Today I came across a weird issue with JavaScript’s Date.UTC() shifting the month by one. The day and year were fine, but the month was off by one. Interesting, considering that the date was parsed from a standard MySQL date (like 2013-07-12). Well, another thing they say: when all else fails, read the manual. And that’s where the solution is:
Parameters
- year: A year after 1900.
- month: An integer between 0 and 11 representing the month.
- date: An integer between 1 and 31 representing the day of the month.
Fun.
Ну, тут мне только одно приходит на ум:
What do you mean why? Because f*ck you, that’s why!
:|
JavaScript Date.UTC() with a month off by one | Blog of Leonid Mamchenkov: #javascript #date #utc #error http://t.co/xUrv6VDm7X