note 113607 added to datetime.format

From: Date: Mon, 04 Nov 2013 11:02:57 +0000
Subject: note 113607 added to datetime.format
Groups: php.notes 
Request: Send a blank email to php-notes+get-197432@lists.php.net to get a copy of this message
Seems like datetime::format does not really support microseconds as the documentation under date suggest it will. Here is some code to generate a datetime with microseconds and timezone: private function udate($format = 'u', $utimestamp = null) { if (is_null($utimestamp)) $utimestamp = microtime(true); $timestamp = floor($utimestamp); $milliseconds = round(($utimestamp - $timestamp) * 1000000); return date(preg_replace('(?<!\\\\)u', $milliseconds, $format), $timestamp); } echo udate('Y-m-d H:i:s.u T'); // Will output something like: 2014-01-01 12:20:24.42342 CET ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/datetime.format.php Edit -- https://master.php.net/note/edit/113607 Del: integrated -- https://master.php.net/note/delete/113607/integrated Del: useless -- https://master.php.net/note/delete/113607/useless Del: bad code -- https://master.php.net/note/delete/113607/bad+code Del: spam -- https://master.php.net/note/delete/113607/spam Del: non-english -- https://master.php.net/note/delete/113607/non-english Del: in docs -- https://master.php.net/note/delete/113607/in+docs Del: other reasons-- https://master.php.net/note/delete/113607 Reject -- https://master.php.net/note/reject/113607 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197432) next »