跳转到主内容

时间

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

功能

显示当前时间戳。

示例配置

{
"type": "time",
"style": "plain",
"foreground": "#007ACC",
"options": {
"time_format": "15:04:05"
}
}

选项

NameTypeDefaultDescription
time_formatstring15:04:05Format to use

模板 (信息)

默认模板
 {{ .CurrentDate | date .Format }}

属性

NameTypeDescription
.FormatstringThe time format (set via time_format)
.CurrentDatetimeThe time to display (testing purpose)

语法

格式

遵循 golang 日期时间标准

DateTimeFormat
Year06, 2006
Month01, 1, Jan, January
Day02, 2, _2 (width two, right justified)
WeekdayMon, Monday
Hours03, 3, 15
Minutes04, 4
Seconds05, 5
ms μs ns.000, .000000, .000000000
ms μs ns (trailing zeros removed).999, .999999, .999999999
am/pmPM, pm
TimezoneMST
Offset-0700, -07, -07:00, Z0700, Z07:00

预定义格式

以下预定义的日期和时间戳 格式常量 也可用:

NameFormat
ANSICMon Jan _2 15:04:05 2006
UnixDateMon Jan _2 15:04:05 MST 2006
RubyDateMon Jan 02 15:04:05 -0700 2006
RFC82202 Jan 06 15:04 MST
RFC822Z02 Jan 06 15:04 -0700
RFC850Monday, 02-Jan-06 15:04:05 MST
RFC1123Mon, 02 Jan 2006 15:04:05 MST
RFC1123ZMon, 02 Jan 2006 15:04:05 -0700
RFC33392006-01-02T15:04:05Z07:00
RFC3339Nano2006-01-02T15:04:05.999999999Z07:00
Kitchen3:04PM
StampJan _2 15:04:05
StampMilliJan _2 15:04:05.000
StampMicroJan _2 15:04:05.000000
StampNanoJan _2 15:04:05.000000000

示例

要显示多个时区的时间,可使用 Sprig 的日期函数

{{ .CurrentDate | date .Format }} {{ dateInZone "15:04Z" .CurrentDate "UTC" }}