On this page本页内容
$millisecond¶Returns the millisecond portion of a date as an integer between 0 and 999.以0到999之间的整数形式返回日期的毫秒部分。
The $millisecond expression has the following operator expression syntax:$millisecond表达式具有以下运算符表达式语法:
Changed in version 3.6.在版本3.6中更改。
The argument must be a valid expression that resolves to one of the following:参数必须是解析为以下之一的有效表达式:
New in version 3.6.版本3.6中的新功能。
date |
<dateExpression> must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID.<dateExpression>必须是解析为日期、时间戳或ObjectID的有效表达式。 | ||||||
timezone |
|
| Result | |
|---|---|
| 0 | |
| 0 | |
| 0 | |
| 0 | |
| 0 | |
error | |
error | |
error |
Note
$millisecond cannot take a string as an argument.不能将字符串作为参数。
Consider a 考虑一个sales collection with the following document:sales集合带有以下文档:
The following aggregation uses the 以下聚合使用$millisecond and other date operators to break down the date field:$millisecond和其他日期运算符来分解date字段:
The operation returns the following result:操作返回以下结果: