note 69683 deleted from function.date by colder
| From: | colder@php.net | Date: | Fri, 15 Sep 2006 08:54:23 +0000 |
| Subject: | note 69683 deleted from function.date by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-117213@lists.php.net to get a copy of this message | ||
Note Submitter: andysharp at swbell dot net
Reason: bad code
----
I have found using date and strtotime together is a quick way to convert between PHP and MySQL date
formats.
e.g.
//In the web form...
<input name="frmDate" type="text" value="<?php echo
date("m/d/y",strtotime($row["dbDate"])); ?>" />
//then saving to the database...
UPDATE TBL01 SET dbDate =
'".date("Y-m-d",strtotime($_REQUEST["frmDate"]))."';
You can use Javascript on your form to make sure you get a valid date, or handle the variable before
injecting it into your query.