note 69683 added to function.date
| From: | andysharp at swbell dot net | Date: | Fri, 15 Sep 2006 02:27:43 +0000 |
| Subject: | note 69683 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117209@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 66.163.161.117
Probable Submitter: 71.155.169.225
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/69683
Del: integrated -- https://master.php.net/note/delete/69683/integrated
Del: useless -- https://master.php.net/note/delete/69683/useless
Del: bad code -- https://master.php.net/note/delete/69683/bad+code
Del: spam -- https://master.php.net/note/delete/69683/spam
Del: non-english -- https://master.php.net/note/delete/69683/non-english
Del: in docs -- https://master.php.net/note/delete/69683/in+docs
Del: other reasons-- https://master.php.net/note/delete/69683
Reject -- https://master.php.net/note/reject/69683
Search -- https://master.php.net/manage/user-notes.php