note 122011 added to class.mongodate

From: Date: Tue, 12 Dec 2017 07:08:28 +0000
Subject: note 122011 added to class.mongodate
Groups: php.notes 
Request: Send a blank email to php-notes+get-209353@lists.php.net to get a copy of this message
MichaelBrenden -- How do the two Mongo drivers determine if they can translate something into the ISODate format? Does mongo.so require a class type of MongoDate, or does it determine by data returned by __toString() (i.e., "0.12345678 1234567890")? Does mongodb.so require a class type of \MongoDB\BSON\UTCDateTime, or does it determine by data returned by __toString() (i.e., "1234567890123")? jmikola >> the ISODate format? For the record, ISODate is just a helper function in the mongo shell. The actual BSON type is 0x09 in the BSON spec and is best referred to as "UTC date time". [url]https://docs.mongodb.com/manual/core/shell-types/#return-date[/url] [url]http://bsonspec.org/spec.html[/url] >> Does mongodb.so require a class type of \MongoDB\BSON\UTCDateTime, or does it determine by >> data returned by __toString() (i.e., "1234567890123")? The driver requires a MongoDB\BSON\UTCDateTime object in order to encode a BSON date type. The relevant instanceof check during BSON encoding is here if you care to see it. The __toString() function exists purely as a convenience for userland applications. The driver does not use it outside of tests. [url]https://github.com/mongodb/mongo-php-driver/blob/1.3.4/src/bson-encode.c#L215[/url] The legacy mongo.so driver is similar in that it requires a MongoDate object in order to encode a BSON date type (relevant code is here). [url]https://github.com/mongodb/mongo-php-driver-legacy/blob/1.6.16/bson.c#L273[/url] ---- Server IP: 208.43.231.9 Probable Submitter: 108.28.193.194 ---- Manual Page -- http://php.net/manual/en/class.mongodate.php Edit -- https://master.php.net/note/edit/122011 Del: integrated -- https://master.php.net/note/delete/122011/integrated Del: useless -- https://master.php.net/note/delete/122011/useless Del: bad code -- https://master.php.net/note/delete/122011/bad+code Del: spam -- https://master.php.net/note/delete/122011/spam Del: non-english -- https://master.php.net/note/delete/122011/non-english Del: in docs -- https://master.php.net/note/delete/122011/in+docs Del: other reasons-- https://master.php.net/note/delete/122011 Reject -- https://master.php.net/note/reject/122011 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209353) next »