TimestampToDateTime (Azure Cosmos DB)TimestampToDateTime (Azure Cosmos DB)

适用于: SQL API

将指定的时间戳值转换为日期/时间。Converts the specified timestamp value to a DateTime.

语法Syntax

TimestampToDateTime (<Timestamp>)

参数Arguments

TimestampTimestamp

一个有符号的数值,即自 Unix 纪元以来当前已经过的毫秒数。A signed numeric value, the current number of milliseconds that have elapsed since the Unix epoch. 换句话说,返回自 1970 年 1 月 1 日星期四 00:00:00 以来已经过的毫秒数。In other words, the number of milliseconds that have elapsed since 00:00:00 Thursday, 1 January 1970.

返回类型Return types

YYYY-MM-DDThh:mm:ss.fffffffZ 格式返回 UTC 日期和时间 ISO 8601 字符串值,其中:Returns the UTC date and time ISO 8601 string value in the format YYYY-MM-DDThh:mm:ss.fffffffZ where:

格式Format 描述Description
YYYYYYYY 四位数的年份four-digit year
MMMM 两位数的月份(01 = 1 月,依此类推。)two-digit month (01 = January, etc.)
DDDD 两位数的月份日期(01 到 31)two-digit day of month (01 through 31)
TT 时间元素开头的符号signifier for beginning of time elements
hhhh 两位数的小时(00 到 23)two-digit hour (00 through 23)
MMmm 两位数的分钟(00 到 59)two-digit minutes (00 through 59)
ssss 两位数的秒(00 到 59)two-digit seconds (00 through 59)
.fffffff.fffffff 七位数的小数秒seven-digit fractional seconds
ZZ UTC(协调世界时)指示符UTC (Coordinated Universal Time) designator

备注Remarks

如果指定的时间戳值无效,TimestampToDateTime 将返回 undefinedTimestampToDateTime will return undefined if the timestamp value specified is invalid.

示例Examples

以下示例将时间戳转换为日期/时间:The following example converts the timestamp to a DateTime:

SELECT TimestampToDateTime(1594227912345) AS DateTime
[
    {
        "DateTime": "2020-07-08T17:05:12.3450000Z"
    }
]

后续步骤Next steps