note 108970 added to class.datetime

From: Date: Fri, 08 Jun 2012 17:03:28 +0000
Subject: note 108970 added to class.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-188470@lists.php.net to get a copy of this message
DateTime does not support split seconds (microseconds or milliseconds etc.) I don't know why this isn't documented. The class constructor will accept them without complaint, but they are discarded. There does not appear to be a way to take a string like "2012-07-08 11:14:15.638276" and store it in an objective form in a complete way. So you cannot do date math on two strings such as: <?php $d1=new DateTime("2012-07-08 11:14:15.638276"); $d2=new DateTime("2012-07-08 11:14:15.889342"); $diff=$d2->diff($d1); print_r( $diff ) ; /* returns: DateInterval Object ( [y] => 0 [m] => 0 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [invert] => 0 [days] => 0 ) */ ?> You get back 0 when you actually want to get 0.251066 seconds. ---- Server IP: 85.19.212.230 Probable Submitter: 174.46.204.210 ---- Manual Page -- http://www.php.net/manual/en/class.datetime.php Edit -- https://master.php.net/note/edit/108970 Del: integrated -- https://master.php.net/note/delete/108970/integrated Del: useless -- https://master.php.net/note/delete/108970/useless Del: bad code -- https://master.php.net/note/delete/108970/bad+code Del: spam -- https://master.php.net/note/delete/108970/spam Del: non-english -- https://master.php.net/note/delete/108970/non-english Del: in docs -- https://master.php.net/note/delete/108970/in+docs Del: other reasons-- https://master.php.net/note/delete/108970 Reject -- https://master.php.net/note/reject/108970 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188470) next »