note 81730 added to function.preg-replace

From: Date: Tue, 11 Mar 2008 15:48:05 +0000
Subject: note 81730 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-136933@lists.php.net to get a copy of this message
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. ---- Server IP: 208.69.120.35 Probable Submitter: 68.197.237.203 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/81730 Del: integrated -- https://master.php.net/note/delete/81730/integrated Del: useless -- https://master.php.net/note/delete/81730/useless Del: bad code -- https://master.php.net/note/delete/81730/bad+code Del: spam -- https://master.php.net/note/delete/81730/spam Del: non-english -- https://master.php.net/note/delete/81730/non-english Del: in docs -- https://master.php.net/note/delete/81730/in+docs Del: other reasons-- https://master.php.net/note/delete/81730 Reject -- https://master.php.net/note/reject/81730 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136933) next »