note 81730 deleted from function.preg-replace by felipe

From: Date: Sun, 23 Mar 2008 22:58:39 +0000
Subject: note 81730 deleted from function.preg-replace by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137392@lists.php.net to get a copy of this message
Note Submitter: mail at gregorypatmore dot com ---- Using php 5.2 and MySQL 5.0 I was having problems formatting dates from MySQL TIMESTAMP field values. It was producing an errant date. So I wrote a function to convert it into a php timestamp that will work correctly with the date() function: <?php function convertTimestamp($ts){ $ts = explode(' ', $ts); $ts[0] = implode( '-', array_reverse(explode('-',$ts[0])) ); return strtotime(implode(' ', $ts)); } ?> Hope this helps somebody.

« previous php.notes (#137392) next »