Javascript: query with Date.UTC

Status
Not open for further replies.
Looking for some clear heads, either I'm going mad or missing something obvious...

I'm passing variables into the JS Date.UTC function in my code but some values are giving odd results.

e.g.
var msDateA = Date.UTC(2017, 1, 31);
var msDateB = Date.UTC(2017, 2, 2);

...gives the number of milliseconds to 2nd February 2017 as less than the number to 31st January 2017?

whilst...

var msDateA = Date.UTC(2017, 1, 31);
var msDateB = Date.UTC(2017, 2, 3);

...gives the same number of milliseconds to the 3rd February 2017 as to 31st January 2017?

What am I missing or completely overlooking?
 

Drizzt321

Ars Legatus Legionis
34,922
Subscriptor++
[url=http:/civis/viewtopic.php?p=32659095#p32659095:1wvlqlfv said:
zero cool[/url]":1wvlqlfv]I suggest you look into something like https://momentjs.com, which makes dates with js much easier to work with.

You just blew my mind. Thank you.

Even though I don't work much in JS, this is going to be amazing to show co-workers.
 
Status
Not open for further replies.