note 15352 added to function.date

From: Date: Thu, 06 Sep 2001 15:14:05 +0000
Subject: note 15352 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-17727@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. http://www.php.net/manual/en/function.date.php

« previous php.notes (#17727) next »