DateTimeToTimestamp (Azure Cosmos DB)DateTimeToTimestamp (Azure Cosmos DB)

适用于: SQL API

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

语法Syntax

DateTimeToTimestamp (<DateTime>)

参数Arguments

DateTimeDateTime
YYYY-MM-DDThh:mm:ss.fffffffZ 格式的 UTC 日期和时间 ISO 8601 字符串值,其中: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

返回类型Return types

返回一个有符号的数值,表示自 Unix 纪元以来当前已经过的毫秒数,即自 1970 年 1 月 1 日星期四 00:00:00 以来已经过的毫秒数。Returns a signed numeric value, the current number of milliseconds that have elapsed since the Unix epoch i.e. the number of milliseconds that have elapsed since 00:00:00 Thursday, 1 January 1970.

备注Remarks

如果指定的日期/时间值无效,DateTimeToTimestamp 将返回 undefinedDateTimeToTimestamp will return undefined if the DateTime value specified is invalid

示例Examples

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

SELECT DateTimeToTimestamp("2020-07-09T23:20:13.4575530Z") AS Timestamp
[
    {
        "Timestamp": 1594336813457
    }
]

再提供一个示例:Here's another example:

SELECT DateTimeToTimestamp("2020-07-09") AS Timestamp
[
    {
        "Timestamp": 1594252800000
    }
]

后续步骤Next steps