Questions tagged [mongodate]
28 questions
5
votes
0 answers
PHP MongoDate: Invalid output with MongoDate->toDateTime()
I have a strange error with MongoDate.
First: The system is a virtual machine on a mac server.
Linux vm 3.16.0-33-generic #44~14.04.1-Ubuntu SMP Fri Mar 13 10:32:52 UTC 2015 i686 i686 i686 GNU/Linux

Patrick
- 51
- 3
3
votes
1 answer
PHP MongoDate toDateTime default timezone
When I create new DateTime object, it has timezone from "date.timezone" setting:
print_r(new DateTime());
DateTime Object
(
[date] => 2015-03-02 03:19:50.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
But when I get…

jonasasx
- 123
- 1
- 1
- 9
2
votes
1 answer
Query only "sec" field from MongoDate using PHP
I have a string converted to MongoDate using
$dateAdded = new MongoDate(strtotime("$time"));
echo "date ".$dateAdded;
So my $dateAdded now looks like 0.00000000 1482505458.
(Here 1482505458 is the number of seconds and 0.00000000 is in…

Anubhav
- 147
- 1
- 13
2
votes
0 answers
PHP MongoDate compare vs stringdate compare
I am trying to create a Mongo query in PHP. I am working with a database created by someone else, and all the dates have been saved as strings. I want to find all the entries that were created before a certain time.
By searching online, I found…

user1795370
- 332
- 2
- 4
- 18
2
votes
3 answers
PHP - Compare two mongodates
Can i compare 2 mongodates like below? In my testing it is working good. But mongodates are objects and will they work the same way in future as well?
$d1 = new MongoDate(1391671630);
$d2 = new MongoDate(1391671631);
echo ($d1 < $d2); //returns 1…

user10
- 5,186
- 8
- 43
- 64
1
vote
2 answers
Unserialize PHP string with obsolete MongoId and MongoDate Objects
I have this string in database.
I need to unserialize it with php.
The problem is that it returns some "__PHP_Incomplete_Class_Name" Objects.
I know that this string was serialized with old MongoDB PHP extension and I try to unserialized with newer…

koAndy
- 27
- 6
1
vote
1 answer
MongoDB Java driver - date query
I am new to MongoDB and Java and I am trying to retrieve data from MongoDB using a date field.
Data:
{
"_id" : {
"timeSlice" : [
2018,
5,
1
],
"type" : "TRANSMISSION",
…

janopan
- 47
- 9
1
vote
2 answers
MongoDB ISODate query with PHP
I am trying to retrieve data from mongo collection based on date, I want to get data where the date is greater or equal to the present day's date (i.e. the date under the data field). However I can't seem to understand why my query returns nothing…

Just Ice
- 179
- 1
- 1
- 11
1
vote
2 answers
Php Mongodate Converting Date to 1970
Hello guys I 'm storing date in mongodb. The problem that I'm facing is that the date time string that I get. I try to convert it into mongodate but it converts it to 0.00000000 2016. Here is the code
$params['start'] = new…

garden
- 309
- 2
- 4
- 16
1
vote
1 answer
Insert MongoDB ISODate PHP
I am using the following versions:
PHP -> 5.6.11
MongoDB -> 3.2
MongoDB PHP Driver -> 1.1
When I was looking to install a MongoDB PHP driver here I noticed that the driver named "Mongo" had been deprecated and…

Douglas Tober
- 300
- 4
- 15
1
vote
2 answers
PHP Monolog doesn't store datetime in ISODate format
The PHP IDS system expose uses Monolog to store logs into MongoDB. The following is how it stores a log:
{
"message": "Executing on data 4f2793132469524563fa9b46207b21ee",
"context": [
],
"level": NumberLong(200),
"level_name": "INFO",
…

RedGiant
- 4,444
- 11
- 59
- 146
1
vote
1 answer
PHP MongoDate/DateTime bug or missunderstanding
Is there something wrong with the MongoDate feature?
When I convert a DateTime Object to MongoDate, and then I try to convert it back to DateTime, I get a totally different value. Keep in mind we're talking about a date within the EPOCH…
user591272
1
vote
3 answers
mongodb date not matching with the given value
While inserting data into mongodb collection I enter the date as '20-06-2015'
and then convert it to mongo format using:
new MongoDate(strtotime(ClearContent(date("Y-m-d",strtotime($start_date)))));
But now when I check in database it shows…

vatsal shah
- 30
- 7
1
vote
1 answer
How to format the retrieving mongo date in sails framework?
This is my mongo db document
{
"creatorUid": "1234",
"creatorUserName": "userabc",
"title": "this is the first thread",
"description": "I like this thread and try to read it",
"threadOwner":…

gihandilanka
- 585
- 6
- 14
1
vote
2 answers
How do you check if a PHP object is a MongoDate object?
Is there a function like MongoId::isValid($id)? How do you determine if an object is a MongoDate object? Check if $mongoDateObject->sec isset()?

Chandrew
- 16,987
- 4
- 24
- 40