Shane
Shane

Reputation: 5677

Date object throwing invalid date with timezones

I have a piece of code like below, which produces an invalid Date.

var pickedUpDate = new Date(val + 'T13:00:00');

I am not sure what this piece of code does with 'T13:00:00'. The val i am passing is like "11/11/2222".

In the later stage, i am using it like below:

if (pickedUpDate < currentDate.setHours(0, 0, 0, 0)) {

}

Upvotes: 2

Views: 39

Answers (1)

laurent
laurent

Reputation: 90776

This is an ISO date with a format like 'yyyy-mm-ddThh:mm:ss' so you should set your val to something like 2017-12-30 so that it gives 2017-12-30T13:00:00.

Upvotes: 2

Related Questions