思源笔记社区正在搭建中,现邀您共建
SiYuan Community is under construction. Join us to co-build.
nowagoago 函数返回从 time.Now 开始计算的时间间隔,以秒为单位。ago .CreatedAt"time.Duration String() 格式返回 2h34m7sdatedate 函数可以格式化日期年-月-日now | date "2006-01-02"1月2日 15:04:05 2006年dateInZonedate 类似,但包含时区信息dateInZone "2006-01-02" (now) "UTC"durationtime.Durationduration 951m36sdurationRoundtime.Duration 作为时间间隔,而 time.Time 则计算为时间间隔。durationRound "2h10m5s"2hdurationRound "2400h10m5s"3mounixEpochtime.Time 自 Unix 时刻以来的秒数now | unixEpochdateModify, mustDateModifydateModify 接受一个修改量和一个日期,并返回时间戳now | date_modify "-1.5h"dateModify 将返回日期未修改的结果。否则 mustDateModify 将返回错误。htmlDatehtmlDate 函数将日期格式化为 HTML 日期选择器的输入字段的格式。now | htmlDatehtmlDateInZonehtmlDate 相同,但包含时区信息htmlDateInZone (now) "UTC"toDate, mustToDatetoDate 将字符串转换为日期toDate 如果不能转换字符串,则返回零值mustToDate 如果字符串无法转换,则返回错误toDate "2006-01-02" "2017-12-31" | date "02/01/2006""2017-12-31" 转换为 "31/12/2017"