Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
返回当前 UTC 时间,可以选择偏移给定的时间跨度。
当前 UTC 时间在单个查询语句中 now() 的所有使用中将保持不变,即使从技术上讲,每个 now() 的运行时间之间存在很小的时间差。
语法
now([ offset ])
详细了解语法约定。
参数
| 客户 | 类型 | 必需 | 说明 |
|---|---|---|---|
| offset | timespan |
要加到当前 UTC 时钟时间的时间跨度。 默认值为 0。 |
返回
以 datetime 形式返回当前 UTC 时钟时间加上 offset 时间(如果有)。
示例
显示当前时间
print now()
显示 2 天前的时间
print now(-2d)
查看从给定事件开始经过的时间
以下示例显示自风暴事件开始起经过的时间。
StormEvents
| extend Elapsed=now() - StartTime
| take 10
获取相对于特定时间间隔的日期
let T = datatable(label: string, timespanValue: timespan) [
"minute", 60s,
"hour", 1h,
"day", 1d,
"year", 365d
];
T
| extend timeAgo = now() - timespanValue
输出
| label | timespanValue | timeAgo |
|---|---|---|
| year | 365.00:00:00 | 2022-06-19T08:22:54.6623324Z |
| day | 1.00:00:00 | 2023-06-18T08:22:54.6623324Z |
| hour | 01:00:00 | 2023-06-19T07:22:54.6623324Z |
| minute | 00:01:00 | 2023-06-19T08:21:54.6623324Z |
注意
可使用 ago() 函数来实现此操作。