MongoDB Time Type

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.