0

so I am using the input type="date" in my form and it shows mm/dd/yyyy and my current code in my form is <input type="date" value="<?= $row['bdate']; ?>"> and it still shows mm/dd/yyyy instead of a date like 10/01/1992. Is there a way to accomplish a thing like that?

2 Answers 2

1

The date should take the format YYYY-MM-DD. Single digit days and months should be padded with a 0. January is 01.

A string representing a date.

Value: A valid full-date as defined in [RFC 3339], with the additional qualification that the year component is four or more digits representing a number greater than 0.

<input type="date" value="2013-01-08">

Demo fiddle

Sign up to request clarification or add additional context in comments.

Comments

1

Change the format while setting the value. Try with -

<input type="date" value="<?= date('d/m/Y', strtotime($row['bdate'])); ?>">

Or -

<input type="date" value="<?= date('d/m/Y', strtotime(str_replace("/", "-", $row['bdate']))); ?>">

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

2 Comments

Thanks for this. Tried and still the same
Still getting mm-dd-yyyy :(

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.