note 120091 added to class.mongodb-bson-utcdatetime

From: Date: Thu, 27 Oct 2016 02:10:00 +0000
Subject: note 120091 added to class.mongodb-bson-utcdatetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-206963@lists.php.net to get a copy of this message
Be careful using UTCDateTime if you need microsecond precision as this class only stores time to the _millisecond_. You need to store the date as a string in MongoDB if you want the full precision. Casting DateTime to a float can also remove precision. An easy way to see the differences is with: Code: var_dump( (new DateTime)->format('U.u'), (float) (new DateTime)->format('U.u'), (new MongoDB\BSON\UTCDateTime())->toDateTime()->format('U.u') ); Output: string(17) "1477534060.918415" double(1477534060.9185) string(17) "1477534060.918000" NOTE: Lots of bugs concerning microsecond formatting for DateTimeInterface classes were fixed as of PHP 7.1.0 RC4. The above code is from PHP 7.1.0 RC5 and mongodb 1.2.0alpha3. The 1.2.0 version of the extension added the ability to instantiate this class without passing integer milliseconds. ---- Server IP: 72.52.91.14 Probable Submitter: 173.216.77.191 ---- Manual Page -- http://php.net/manual/en/class.mongodb-bson-utcdatetime.php Edit -- https://master.php.net/note/edit/120091 Del: integrated -- https://master.php.net/note/delete/120091/integrated Del: useless -- https://master.php.net/note/delete/120091/useless Del: bad code -- https://master.php.net/note/delete/120091/bad+code Del: spam -- https://master.php.net/note/delete/120091/spam Del: non-english -- https://master.php.net/note/delete/120091/non-english Del: in docs -- https://master.php.net/note/delete/120091/in+docs Del: other reasons-- https://master.php.net/note/delete/120091 Reject -- https://master.php.net/note/reject/120091 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206963) next »