MedMatrix
MedMatrix

Reputation: 336

Datetime-local input doesn't accept the specified value

I have a datetime-local input.

I wish I had the ability to mandatory specify a date and optionally an hour.

Only, even when I indicate both, a warning occurs preventing me to get the input value.

Here is the warning message in question:

The specified value "0000-00-00T00:00" does not conform to the required format. The format is "yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS".

I don't see where does the error or how to solve it.

Upvotes: 2

Views: 5227

Answers (3)

ABC
ABC

Reputation: 212

moment(new Date()).format('YYYY-MM-DDTHH:mm')

Using moment.js it works with this format for type="datetime-local"

Upvotes: 7

Tommy Nguyen
Tommy Nguyen

Reputation: 116

The datetime-local input accepts date value in the format: {date-value}T{time-value} and {time-value} shouldn't contain the UTC part. So I suppose the problem is in your date value because "00" is not a valid value for day or month

Upvotes: 1

Gromish
Gromish

Reputation: 199

The format is valid, the date is invalid: 0th of month 0 of year 0 don't exists.

Upvotes: 2

Related Questions