On this page本页内容
$dateToString¶Converts a date object to a string according to a user-specified format.根据用户指定的格式将日期对象转换为字符串。
The $dateToString expression has the following operator expression syntax:$dateToString表达式具有以下运算符表达式语法:
The $dateToString takes a document with the following fields:$dateToString采用带有以下字段的文档
date |
The date to convert to string. | ||||||
format |
If unspecified, Changed in version 4.0:The | ||||||
timezone |
| ||||||
onNull |
New in version 4.0:Requires |
The following format specifiers are available for use in the 以下格式说明符可在<formatString>:<formatString>中使用:
%d |
01-31 | |
%G |
|
0000-9999 |
%H |
00-23 | |
%j |
001-366 | |
%L |
000-999 | |
%m |
01-12 | |
%M |
00-59 | |
%S |
00-60 | |
%w |
1-7 | |
%u |
|
1-7 |
%U |
00-53 | |
%V |
|
01-53 |
%Y |
0000-9999 | |
%z |
|
+/-[hh][mm] |
%Z |
|
+/-mmm |
%% |
% |
Consider a 考虑一个sales collection with the following document:sales集合与以下文件:
The following aggregation uses 以下聚合使用$dateToString to return the date field as formatted strings:$dateToString将date字段作为格式化字符串返回:
The operation returns the following result:操作返回以下结果: