mongdb Time Type
- Date () Displays the current time
- New date constructs a Greenwich time can see exactly and Date () Difference 8 hours, we are 8 time zone, that is, the difference between 8, so + 8 hours is the current system
- Isodate () is also Greenwich
>: $ gmt+0800 (CST)> new Date () isodate ("2016-01-24t12:40:24.035z")> Isodate () isodate ("2016-01-24t12:52:33.341z")
View Type
> typeof date ()string> typeof new Date ()object
Time stamp
> isodate ("2016-01-24t12:52:33.341z"). ValueOf ()1453639953341
Find
>db.tb1.Find({ Time: {$gt: New Date (1363746981289)}) supports multiple formats:> Db.tb1.insert ({mydate:isodate ("2012-11-02 07:58:51")})> Db.tb1.insert ({mydate:isodate ("20121102 07:58:51")})> Db.tb1.insert ({mydate:isodate ("20121102")}) can also be directly manipulated:>db.tb1.Find({"mydate": {$gt: Isodate ("2012-10-02t07:58:51z")}) and DB.TB1.Find({"mydate": {$gt: New Date ("2012-10-02t07:58:51z")}}) is the same
Store
When MongoDB stores time-type data, it is converted to UTC time and then stored in the database
toLocaleString () returns the time string containing the current time zone information
> isodate ("2016-01-24t12:52:33.341z"): £ º gmt+0800 (CST)
MongoDB Time Type