note 32478 deleted from function.strtotime by sniper
| From: | sniper@php.net | Date: | Tue, 21 Oct 2003 11:01:35 +0000 |
| Subject: | note 32478 deleted from function.strtotime by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58998@lists.php.net to get a copy of this message | ||
Note Submitter: berniegz@hotmail.com
----
I've had a hard time dealing with 'timestamps with time zone' in Postgres, and the
comments here didn't help much (specifically the one about adding on '00' to the end
of the timestamp). So, I've decided to post a trick I've used to easily get a date I can
work with from the database:
$sql = "SELECT stamp FROM table";
$res = pg_query($connection, $sql);
$row = pg_fetch_array($res);
$datetime = $row['stamp'];
$datetime = substr($datetime, 0, -3);
$datetime = strtotime($datetime);
$datetime = date("F j, Y g:i A", strtotime("-2 hours", $datetime));
print($datetime) now gives something like "May 28, 2003 12:22 PM."
Note: You can leave the 2nd strtotime() out if you don't need to do a time zone conversion:
$datetime = date("F j, Y g:i A", $datetime);