note 15352 deleted from function.date by jimw
| From: | jimw@php.net | Date: | Fri, 02 Nov 2001 01:13:22 +0000 |
| Subject: | note 15352 deleted from function.date by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20105@lists.php.net to get a copy of this message | ||
To change the PostgreSQL TIMESTAMP to a PHP viable Unix timestamp eliminate the time zone stuff from
the end of the string:
// simulate a PostgreSQL timestamp
$timestamp = "2001-09-05 21:12:45-04";
// Eliminates the "-04"
$timestamp = substr($timestamp, 0, -3);
$unix_time = strtotime($timestamp);
// Now I can convert it:
echo date("F j, Y, g:i a", $unix_time);
You can do the same with MySQL but you do not need the substr() call. Make this into a function and
you can use either database interchangeably.