This question already has an answer here:
- Convert one date format into another in PHP 15 answers
(I've had to edit this post since John Conde wrongly marked it as answered because he didn't understand my question.)
In my PHP app, the user should be able to enter a date in any format the strtotime() function understands. Here is the input:
<label>Release Date:</label>
<input type="text" name="release_date"/> <span>Use any valid
date format</span>
<br />
Then the index page draws it from the form and stores it in the database like this...
$release_date = $_POST['release_date'];
and displays it on the list page like this:
<td><?php $date = date('n/j/Y', strtotime($product['releaseDate']));
echo $date; ?></td>
I know how to convert dates from one format to another. The display side is fine. But WHERE and HOW do I take the user input - entered in ANY date format the strtotime() function can interpret - and turn it into a readable format going into the database? Right now if I enter any date not in 'xxxx-xx-xx' format it's read as 0 and comes out as UNIX 0, 1/1/1970.
Thank you.
</div>