note 32478 added to function.strtotime
| From: | berniegz at hotmail dot com | Date: | Wed, 28 May 2003 19:24:42 +0000 |
| Subject: | note 32478 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49202@lists.php.net to get a copy of this message | ||
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);
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32478
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32478&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32478&report=yes