Page 1 of 1

php change date entered format to proper format

Posted: Thu Apr 28, 2011 4:29 pm
by cjkeane
hi everyone.

i'm wondering how i could modify the code below in order to change the date that's entered in the textbox from any date a user inputs eg 28-04-2011, or 28/04/2011 to the proper format of 2011-04-28 (yyyy-mm-dd) and if its text or a number, just clear the data in the textbox. any ideas?

Code: Select all

<?php if ($Date != "0000-00-00") echo $Date; ?>

Re: php change date entered format to proper format

Posted: Thu Apr 28, 2011 6:38 pm
by getmizanur
use regular expression and preg_match function

Re: php change date entered format to proper format

Posted: Thu Apr 28, 2011 8:52 pm
by fugix
is the data being stored and later called or is it being echoed right after submitted?