php change date entered format to proper format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cjkeane
Forum Contributor
Posts: 217
Joined: Fri Jun 11, 2010 1:17 pm

php change date entered format to proper format

Post 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; ?>
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

Re: php change date entered format to proper format

Post by getmizanur »

use regular expression and preg_match function
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: php change date entered format to proper format

Post by fugix »

is the data being stored and later called or is it being echoed right after submitted?
Post Reply