note 112943 added to class.datetimeinterface

From: Date: Fri, 09 Aug 2013 19:40:49 +0000
Subject: note 112943 added to class.datetimeinterface
Groups: php.notes 
Request: Send a blank email to php-notes+get-195925@lists.php.net to get a copy of this message
Making the upgrade from PHP 5.3 to 5.5, I noticed the set of functions I was using to convert a Unix time stamp to a friendly time stamp no longer worked. It's now necessary to set the timezone BEFORE attempting to create a new DateTime object. Below is a function which will convert a Unix time stamp to a human readable format working as of PHP 5.5 function formatTimeStamp($unixTimeStamp) { date_default_timezone_set('America/Chicago'); // a full list of timezones is available at http://php.net/manual/en/timezones.php $time = new DateTime("@" . $unixTimeStamp); return $time->format("Y-m-d H:i:s"); //convert to friendly date stamp } ---- Server IP: 69.147.83.199 Probable Submitter: 173.164.31.125 ---- Manual Page -- http://php.net/manual/en/class.datetimeinterface.php Edit -- https://master.php.net/note/edit/112943 Del: integrated -- https://master.php.net/note/delete/112943/integrated Del: useless -- https://master.php.net/note/delete/112943/useless Del: bad code -- https://master.php.net/note/delete/112943/bad+code Del: spam -- https://master.php.net/note/delete/112943/spam Del: non-english -- https://master.php.net/note/delete/112943/non-english Del: in docs -- https://master.php.net/note/delete/112943/in+docs Del: other reasons-- https://master.php.net/note/delete/112943 Reject -- https://master.php.net/note/reject/112943 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195925) next »