Dynamically inserting dates and times
Quick Overview Video
Summary: You can add to your snippet today's date, the current time or any dates and times in the past or future such as tomorrow's date, the time 3 hours ago, the date of the first Monday of next month, and so on.
Inserting today's date
- When editing a snippet - click on the date menu
- Select the date format you'd like to use
- Try the snippet
Here's a sample snippet you can copy over to your dashboard.
Inserting the current time
- When editing a snippet - click on the time menu
- Select the time format you'd like to use
- Try the snippet
Here's an example:
Presenting dates and times in different formats
You can present the dates and times in different ways. For example, July 4, 1776 at 7:03pm can be shown as (very partial list):
- Thursday, July 4, 1776
- 7/4/1776
- 1776-07-04 at 7pm
- Thursday
- 19:03
- And so on.
To change the way the time is presented:
- In the snippet editing window, click on the time or date command you added (the command "pill")
- Change the
time/date format
setting - Try the snippet
Below is a snippet showing the current date and time in different formats:
You can find all the available formats here
Shifting the date and time
But what if you want to insert yesterday's date? Or the time two hours from now? Move the date/time forward or backward using the shift
setting.
There are two ways to shift the date command:
Option 1 - Shift an existing time command
- Click on the command you added (the command "pill")
- In the
Shift
setting, set the shift unit (Days, Weeks, Months, etc.) - Set the shift value (1, 2, 5, 10, etc.)
- Try the snippet
Option 2 - insert a shifted time command
- Click on the shift menu
- Select the required shifted time
- Try the snippet
The example below shifts today's date forward by 1 day to insert tomorrow's date.
Shifting to the beginning or end of a period
You can also shift the date to the beginning or end of a given period (e.g. week, month, quarter). In the example below, last quarter's number is dynamically presented along with the dates of the first and last days of the quarter.
Setting an anchor date
By default, the current date and time are used as the "anchor", but you can set any other date and time as the anchor. Do that by setting the At
setting.
The example below sets the anchor to be July 4th 1776:
Advanced example
Greeting based on the time of day
This snippet determines the greeting (Good morning, Good evening, etc.) based on the time in which it is inserted.
It uses the H
time format, which gives the current hour (0-24) and an {if}
command to determine the greeting.
Note: The {if}
command is a Pro feature, but you can test it on the free plan.
Calculate the date 91 days from a selected date
This snippet allows you to select a date and writes the date 91 days later.
You'll notice that the date selection is done inside a note
and therefore is not typed when the snippet is inserted.
The date selection is using a Form Date
command (Pro feature) and then sets it as the date "anchor" using the At
setting, which is then shifted by 91 days.
Calculate the date x weekdays from a selected date
Similarly, this snippet asks for a start date and the duration in weekdays and calculates the expected end date.
It uses the Form Date
command to get the date and a Form Text
command to get the duration in weekdays. It then anchors the date to the one selected in the Form Date
and shifts it by the number of weekdays selected in the Form Text
.
Calculate someone's age based on their date of birth
Pretty self-explanatory...
The X
time format produces the current time in seconds (the number of seconds that have passed since 1 Jan 1970).
This snippet uses the Form Date
command to capture the birthdate. Then it calculates the number of seconds currently and at the date of birth. The difference between the two is then converted to years using a formula
.
Calculate the date of a day next week
This snippet calculates the date of a given day next week.
It uses a drop-down menu (the Form Menu
command) to capture the day and then uses a sophisticated shifting to a boundary, with the day set as the boundary.
The Pattern
setting is used to tell Text Blaze what format is used for the "anchor" (The At
setting).
If you'd like to read more, check out the complete documentation page (video included): https://blaze.today/commands/time/