0

while posting a date from a PHP form, I must enter it as YYYY-MM-DD to be accepted. is there a way I can reformat the date as it POSTS so people can enter it as DD-MM-YYYY?

. date("M d, Y", strtotime($_POST['dob'])); 

.. or something?

1 Answer 1

1

It's running fine

<?php echo date("M d, Y", strtotime('12-06-1982')); ?> 

output

Jun 12, 1982 

UPDATE WITH EXAMPLE

HTML

<form action="date.php" method="post"> <input type="text" name="dob"/> <input type="submit" name="submitDate" value="submit"/> </form> 

date.php

<?php if ($_POST['submitDate']){ echo date("M d, Y", strtotime($_POST['dob'])); } ?> 

This will return the date in that format that you want. Simple!

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

4 Comments

yea for ECHO, but is it the same setup for $_POST?
Even this work : echo date("M d, Y", strtotime('2011-07-24 00:00:00'));
now the dates are posted as "12-31-1969" ?? when I enter todays date

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.