Date Module

This module contains every internal function related to dates.

Documentation

Function documentation is using a specific syntax. More information here

tp.date.now(format: string = "YYYY-MM-DD", offset?: numberāŽ®string, reference?: string, reference_format?: string)

Retrieves the date.

Arguments
  • format: Format for the date, refer to format reference

  • offset: Offset for the day, e.g. set this to -7 to get last week's date. You can also specify the offset as a string using the ISO 8601 format

  • reference: The date referential, e.g. set this to the note's title

  • reference_format: The date reference format.

tp.date.tomorrow(format: string = "YYYY-MM-DD")

Retrieves tomorrow's date.

Arguments

tp.date.weekday(format: string = "YYYY-MM-DD", weekday: number, reference?: string, reference_format?: string)

Arguments
  • format: Format for the date, refer to format reference

  • reference: The date referential, e.g. set this to the note's title

  • reference_format: The date reference format.

  • weekday: Week day number. If the locale assigns Monday as the first day of the week, 0 will be Monday, -7 will be last week's day.

tp.date.yesterday(format: string = "YYYY-MM-DD")

Retrieves yesterday's date.

Arguments

Moment.js

Templater gives you access to the moment object, with all of its functionalities.

More information on moment.js here

Examples

Date now: <% tp.date.now() %>
Date now with format: <% tp.date.now("Do MMMM YYYY") %>

Last week: <% tp.date.now("dddd Do MMMM YYYY", -7) %>
Today: <% tp.date.now("dddd Do MMMM YYYY, ddd") %>
Next week: <% tp.date.now("dddd Do MMMM YYYY", 7) %>

Last month: <% tp.date.now("YYYY-MM-DD", "P-1M") %>
Next year: <% tp.date.now("YYYY-MM-DD", "P1Y") %>

File's title date + 1 day (tomorrow): <% tp.date.now("YYYY-MM-DD", 1, tp.file.title, "YYYY-MM-DD") %>
File's title date - 1 day (yesterday): <% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>

Date tomorrow with format: <% tp.date.tomorrow("Do MMMM YYYY") %>    

This week's monday: <% tp.date.weekday("YYYY-MM-DD", 0) %>
Next monday: <% tp.date.weekday("YYYY-MM-DD", 7) %>
File's title monday: <% tp.date.weekday("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD") %>
File's title next monday: <% tp.date.weekday("YYYY-MM-DD", 7, tp.file.title, "YYYY-MM-DD") %>

Date yesterday with format: <% tp.date.yesterday("Do MMMM YYYY") %>