note 46134 deleted from function.getdate by tomsommer
| From: | tomsommer@php.net | Date: | Tue, 26 Oct 2004 23:16:09 +0000 |
| Subject: | note 46134 deleted from function.getdate by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79149@lists.php.net to get a copy of this message | ||
Note Submitter: Mison
----
If you want to insert a date into a mysql date field, you need to ensure it's correctly
formatted else it goes in as 0000-00-00 (not good!)
These two lines of code will create the variable $dt ready for insertion
$dte = getdate();
$dt = $dte[year] . "-" . str_pad($dte[mon], 2, "0", STR_PAD_LEFT) .
"-" . str_pad($dte[mday], 2, "0", STR_PAD_LEFT);
example:
2004-09-30