Questions tagged [mongodate]
28 questions
0
votes
0 answers
Adding current Date as new Date() in a string key in mongo db
I am trying yo add the below json to my mongo DB collection, The document has a field named value which is String.
"value" : "{\"name\"\"sample\":{\"maximumDate\":newDate(),\"is24hoursFormat\":true}}"
It is inserted correctly but when I run it, I…

Aditya
- 950
- 8
- 37
0
votes
0 answers
MongoDB database gives me the wrong time from input with type datetime-local
When I write a date in my input I receive the wrong time in the database (2 hours earlier than the time I want), in the pictures you can see that I got the hour 5:21 in the database even though I wrote the time 7:21 in the input:
The time in the…

Gilad Dekel
- 71
- 5
0
votes
1 answer
Is it possible to make a string date comparision inside the mongo $filter cond operator?
In this case, to fetch more compact data from MongoDB, I need to filter subdocument (records) by date value that has a string type. As you can see below, the record document is a nested array.
[
{
"_id": 14,
"isActive": true,
"name":…

p_escobr
- 31
- 1
- 7
0
votes
1 answer
Filter mongodb data by current month
i try to query find by month in mongodb,
my data in Daq collection is like this:
"
_id" : ObjectId("5f14081c14c08a261b816d57"),
"battery_voltage" : 3673,
"total_usage" : 0.483,
"signal" : 14,
"samplehour" :…

Hendriyono
- 15
- 5
0
votes
1 answer
Why aggregate ($date) method is not working in MongoDB
Why below code works
db.getCollection('CustomerData').aggregate([
{$addFields: {
"month": {$month: new Date("2018-09-18T00:00:00.000Z")},
"year": {$year: new Date("2018-09-18T00:00:00.000Z")}
}
},
…

VivekT
- 81
- 2
- 13
0
votes
0 answers
mongodb lte and gte query execution taking too much time
this is my query for find number of record in one hour
$rec=0;
$acst1 = new \MongoDB\BSON\UTCDateTime(strtotime('2017-10-30 21:00:00')*1000);
$acst2 = new \MongoDB\BSON\UTCDateTime(strtotime('2017-10-30 22:00:00')*1000);
…

NIKHIL PARIHAR
- 502
- 6
- 10
0
votes
1 answer
JavaScript formatting json value depending schema
Is there a simple way to vor a value of JSON field depending on format on its JSON Schema (specially date / datetime format for mongodb)?
Examples:
JSON:
{
"firstName": "Alex",
"lastName": "Alex",
"birthDate": "1996-06-20"
}
Schema:
{
…

Nader Sghir
- 81
- 1
- 8
0
votes
0 answers
How to rewrite the MongoDate class so that I can reuse with new mongodb php driver?
We are working on a project which currently uses mongodb and yii framework.We are planning to upgrade our project to php7.But the old monogdb driver depreciated.The MongoDate class is part of the old mongo driver and it is depreciated.How to make it…

Harikrishnan
- 53
- 12
0
votes
1 answer
Create Date Object MongoDB new php driver
I'm trying to create Date Object to create a document in MongoDB with PHP.
I saw in PHP documentation new MongoDate() but I'm using the 'new' drivers MongoDB for PHP7 (this doc) and I can't use this.
I tried with MongoDB\BSON\Date but I got Class…

Miwer
- 3
- 1
0
votes
1 answer
How to use MongoDate in Codeigniter
I have to convert date time before sending to mongodb. By googling found that I should use MongoDate class.
/* Fields */
Class MongoDate {
/* Fields */
public int $sec ;
public int $usec ;
/* Methods */
public __construct ([ int $sec = time() [,…

Zee
- 351
- 1
- 15
0
votes
1 answer
How do I php query regex on a mongodb Date
I have a collection of users and i want to get all the users who registered in 2015.
With a normal date string it is possible tot query:
$query=[
'timestamp'=> [
'$regex' => "2015"
]
];
But when I try this on a MongDate timestamp it…

Tycho
- 131
- 1
- 5
0
votes
1 answer
how to format the mongoDate function properly
I am not sure if I'm doing this right, however the date function seems to display correctly, but for some reason it is returning the time in AM not PM, Example,
Right now, if I was to create a new date using:
$time = new mongoDate();
Then I save…

Shannon Hochkins
- 11,763
- 15
- 62
- 95
0
votes
1 answer
PHP + MongoClient + MongoDate , operand not working on nested elements
I've got an headache that I would like to share with you :)
This is my code (portion of a small project I'm doing in php+mongo):
connect();
$collection =…

Valerio Tesei
- 33
- 4