isodate

Retrieve data from mongodb based on date condition in pymongo

夙愿已清 提交于 2020-01-15 13:21:06
问题 My MongoDB document is as follows: - { "_id" : 111, "ts" : [ ISODate("2010-08-21T23:13:35.000Z"), ISODate("2011-08-23T09:13:10.000Z"), ISODate("2012-08-26T12:55:51.000Z"), ISODate("2010-08-29T03:11:12.000Z") ] } { "_id" : 112, "ts" : [ ISODate("2010-08-21T23:13:35.000Z"), ISODate("2011-08-23T09:13:10.000Z"), ISODate("2012-08-26T12:55:51.000Z"), ISODate("2010-08-29T03:11:12.000Z") ] } Each date entry indicates a "hit". I am trying to count the number of hits each id had between a certain date

Retrieve data from mongodb based on date condition in pymongo

一个人想着一个人 提交于 2020-01-15 13:21:05
问题 My MongoDB document is as follows: - { "_id" : 111, "ts" : [ ISODate("2010-08-21T23:13:35.000Z"), ISODate("2011-08-23T09:13:10.000Z"), ISODate("2012-08-26T12:55:51.000Z"), ISODate("2010-08-29T03:11:12.000Z") ] } { "_id" : 112, "ts" : [ ISODate("2010-08-21T23:13:35.000Z"), ISODate("2011-08-23T09:13:10.000Z"), ISODate("2012-08-26T12:55:51.000Z"), ISODate("2010-08-29T03:11:12.000Z") ] } Each date entry indicates a "hit". I am trying to count the number of hits each id had between a certain date

How to return ISO date format in PHP for MongoDB?

怎甘沉沦 提交于 2020-01-10 14:04:20
问题 I want to store the current date generated from PHP into MongoDB collection as an ISO date formate. ISODate("2012-11-02T08:40:12.569Z") However I am not able to generate such Kind of date in php which will be stored in MongoDB as an ISODate format. This is what I ve done. $d = new MongoDate(time()); echo $d; and it is outputting something like, 0.00000000 1353305590 which is not the format I need. How to do this? 回答1: You could run the __toString function, or use the sec field __toString will

How to return ISO date format in PHP for MongoDB?

你。 提交于 2020-01-10 14:02:32
问题 I want to store the current date generated from PHP into MongoDB collection as an ISO date formate. ISODate("2012-11-02T08:40:12.569Z") However I am not able to generate such Kind of date in php which will be stored in MongoDB as an ISODate format. This is what I ve done. $d = new MongoDate(time()); echo $d; and it is outputting something like, 0.00000000 1353305590 which is not the format I need. How to do this? 回答1: You could run the __toString function, or use the sec field __toString will

MongoDB ISODate query with PHP

好久不见. 提交于 2020-01-05 07:17:31
问题 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 (empty mongo object). Below is my code: Array struct/content: { "_id" : ObjectId("990093409187049704809d"), "type" : "number 1 champion", "entryDate" : ISODate("2016-05-12T10:55:55.000+0000"), "requester" : { "cn" : "Torgue", "username" : "tg" },

JavaScript - How to save a date in MongoDB document in ISODate format?

可紊 提交于 2020-01-02 05:41:21
问题 I have been trying to save the date from javascript side into MongoDB in ISODate format. But it just saves the date field in my MongoDB document in string format. Here is the object I'm sending into the MongoDB to be saved as a document in a given collection. var currentDate = new Date(); postData = { deviceID: deviceID, companyID: companyID, userID: userID, date: currentDate }; Everything works fine except the date field is just saved in String format. Couldn't find any SO question which

Getting unix timestamp in seconds out of MongoDB ISODate during aggregation

给你一囗甜甜゛ 提交于 2019-12-29 05:34:09
问题 I was searching for this one but I couldn't find anything useful to solve my case. What I want is to get the unix timestamp in seconds out of MongoDB ISODate during aggregation. The problem is that I can get the timestamp out of ISODate but it's in milliseconds. So I would need to cut out those milliseconds. What I've tried is: > db.data.aggregate([ {$match: {dt:2}}, {$project: {timestamp: {$concat: [{$substr: ["$md", 0, -1]}, '01', {$substr: ["$id", 0, -1]}]}}} ]) As you can see I'm trying

Storing Utc and Local datetime in Mongo

你说的曾经没有我的故事 提交于 2019-12-28 05:42:24
问题 I have a Mongo C# implementation that stores datetime as UTC. MongoDB.Bson.Serialization.Options.DateTimeSerializationOptions options = MongoDB.Bson.Serialization.Options.DateTimeSerializationOptions.UtcInstance; var serializer = new MongoDB.Bson.Serialization.Serializers.DateTimeSerializer(options); MongoDB.Bson.Serialization.BsonSerializer.RegisterSerializer( typeof(DateTime), serializer); I also have a need to store the user local timezone along with the UTC. To explain, I have two

Storing Utc and Local datetime in Mongo

£可爱£侵袭症+ 提交于 2019-12-28 05:42:17
问题 I have a Mongo C# implementation that stores datetime as UTC. MongoDB.Bson.Serialization.Options.DateTimeSerializationOptions options = MongoDB.Bson.Serialization.Options.DateTimeSerializationOptions.UtcInstance; var serializer = new MongoDB.Bson.Serialization.Serializers.DateTimeSerializer(options); MongoDB.Bson.Serialization.BsonSerializer.RegisterSerializer( typeof(DateTime), serializer); I also have a need to store the user local timezone along with the UTC. To explain, I have two

String of ISO-8601 datetime to number of seconds in Java

我们两清 提交于 2019-12-25 08:54:03
问题 How do I convert a string of ISO-8601 datetime (ex: 2012-05-31T13:48:04Z ) to number of seconds( 10 digit integer ) using Java? 回答1: try this way String DateStr="2012-05-31T13:48:04Z"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); Date d=sdf.parse(DateStr); System.out.println(d.getTime()); output 1338452284000 From the comments of OP getTime() returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.Source 回答2: using