note 24009 deleted from function.date by sniper
| From: | sniper@php.net | Date: | Sat, 18 Jan 2003 01:33:25 +0000 |
| Subject: | note 24009 deleted from function.date by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-42317@lists.php.net to get a copy of this message | ||
[Editors note: Using MySQL's date and time functions is a preferred method, i.e.
UNIX_TIMESTAMP.]
Converting mySQL timestamp to PHP timestamp to use in a date(); function call. Something small and
simple.
function make_time($datetime) {
$yr = substr($datetime,0,4);
$mon = substr($datetime,4,2);
$day = substr($datetime,6,2);
$hr = substr($datetime,8,2);
$min = substr($datetime,10,2);
$sec = substr($datetime,12,2);
return mktime($hr,$min,$sec,$mon,$day,$yr);
}