John Dawson
John Dawson

Reputation: 465

Set date format in HTML form input to YYYY only

I currently have an HTML form with a date input field. Is it possible to set this to the format YYYY only? I am not interested in the days or months and need the year in this format for some PHP processing.

I know I could do some extra work to get the date into the YYYY format afterwards, but I was wondering if there was a way to force the user to supply it in this way?

Upvotes: 0

Views: 4624

Answers (1)

Dave
Dave

Reputation: 987

Not sure if this might work:

<input id="startdate" name="startdate" min="1900" max="2100" type="date">

Upvotes: 1

Related Questions