note 15043 added to function.getdate.php
| From: | aggie at aggie dot dk | Date: | Sat, 25 Aug 2001 11:38:31 +0000 |
| Subject: | note 15043 added to function.getdate.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17116@lists.php.net to get a copy of this message | ||
A lot of people here go into str_replace , and worse, regexes to get some date into a database..
validation of user input being a separate issue, the simplest way to get a date into a mysql
database is to use FROM_UNIXTIME together with a timestamp..
ex:
$timestamp = time(); # or whatever
$sql_string = " INSERT INTO dates ( date_1 ) VALUES ( FROM_UNIXTIME ( {$timestamp} ) ) ";
no need to mess with the timestamp, let SQL handle that..
http://www.php.net/manual/en/function.getdate.php