Question

Now I'm working with objective-c and mongodb.

I use AFNetworking Framework to send the http request from my application to server (bottlepy server) to connect mongodb database.

In mongodb the information I need look like this

{
    "_id" : ObjectId("532083b7a67a6a14589c876e"),
    "myDate" : ISODate("2014-02-08T00:00:00Z")
}

but when I use AFNetworking to get this. It is auto convert to

{
    "_id" = {
        "$oid" = 532083b7a67a6a14589c876e;
    };
    myDate = {
        "$date" = 1391817600000;
    };
}

So How to covert $date to NSDate??? ?

Really Thank you.

Was it helpful?

Solution

NSDate *now = [NSDate dateWithTimeIntervalSince1970:1391817600000/1000];

generates:

2014-02-08 00:00:00 +0000
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top