Template Variables
Date & Time Variables
Comprehensive guide to Date and Time variables in Snipset.
Snipset provides a powerful set of date and time variables to dynamically insert the current timestamp, formatted dates, and even calculate future or past dates.
Basic Date and Time
#{date}- Inserts the current date in the system's default format.#{time}- Inserts the current time in the system's default format.
`Today is #{date} and the time is #{time}.`
Output: Today is 2026-04-22 and the time is 07:34:12.
Formatted Date and Time
You can specify a custom format using chrono formatting tokens (e.g., %Y, %m, %d, %H, %M). Moment.js/Day.js-style tokens such as YYYY or DD do not work here; use datetime_adv for those (see below).
#{date:format}- Formatted date.#{time:format}- Formatted time.#{dateTime:format}- Combined date and time formatting.
`
File backup: backup_#{date:%Y-%m-%d}.zip Meeting at: #{time:HH:mm
a} Full timestamp: #{dateTime:yyyy-MM-dd HH:mm:ss}
`
Output:
`
File backup: backup_2026-04-22.zip Meeting at: 07:34 AM Full timestamp: 2026-04-22 07:34:12
`
Date Math and Offsets
You can calculate future or past dates by applying an offset. The syntax is #{dateTime:+offset:format}.
Note: A format string is mandatory when using date offsets.
- y: Years
- M: Months
- w: Weeks
- d: Days
- h: Hours
- m: Minutes
- s: Seconds
`
Tomorrow: #{dateTime:+1d:yyyy-MM-dd} Next week: #{dateTime:+1w:EEEE,
MMMM do} Yesterday: #{dateTime:-1d:yyyy-MM-dd} In 3 hours:
#{dateTime:+3h:HH:mm}
`
Edge Cases & Limitations
- Missing Format with Offset: If you write
#{dateTime:+1d}without a format, it will not parse correctly. You must include the format parameter:#{dateTime:+1d:yyyy-MM-dd}. - Invalid Format Tokens: If you use an invalid formatting token (like
ZZZZwhere unsupported), Snipset will either ignore the token or output it literally, depending on the underlying rustchronoimplementation. - Leap Years & End of Month: Date math correctly handles leap years and variable month lengths. Adding 1 month to January 31st will safely resolve to the end of February.
Advanced Date Formatting & Shift (New!)
For the ultimate flexibility, Snipset provides the datetime_adv variable. This variable supports friendly Moment.js/Day.js date format tokens, shifted dates, and locale support! The syntax is #{datetime_adv:format|shift|locale}.
`
Current Date: #{datetime_adv:YYYY-MM-DD||} Localized Tomorrow:
#{datetime_adv:dddd, DD MMMM YYYY|+1d|en_US}
`