note 9609 modified in time by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Tue, 14 Nov 2000 23:10:13 +0000 |
| Subject: | note 9609 modified in time by jmcastagnetto | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7701@lists.php.net to get a copy of this message | ||
[Editor's note: A simpler and faster solution is to use the UNIX_TIMESTAMP() function in MySQL
while performing the SQL query, eg.
select *,unix_timestamp(tsfield) ...
See the MySQL manual for more information]
To convert a mysql timestamp (14 Byte) into a unix timestamp:
// This function translates es mysql timestamp to // a unix timestamp
function epoch($timestamp)
{
$hour = substr($timestamp,8,2);
$minute = substr($timestamp,10,2);
$second = substr($timestamp,12,2);
$month = substr($timestamp,4,2);
$day = substr($timestamp,6,2);
$year = substr($timestamp,0,4);
return mktime($hour, $minute, $second, $month, $day, $year);
}
http://www.php.net/manual/function.time.php