Displaying time and dates

The following functions count time and display times and dates. For example, you can use them to display when a design was created or modified, and also to set specific times and dates such as delivery times and elapsed time.

How it works

To display a time period or a date, Prinect uses two types of functions, which work in combination:

  1. Functions for computing time. These count the seconds that have elapsed from 1 January 1970 to a specific moment in time. For example, timenow() produces the number of seconds that have elapsed between 1 January 1970 and the moment the function is called, and ProjectInfo.Created produces the number of seconds from 1 January 1970 to the moment a file was created. These functions produce numbers that you cannot put to any meaningful use.
  2. Functions for displaying time. These use the numbers produced by time-computing functions and convert them into a time or date format that you can actually use. This are the functions that you type in a design frame.

This page walks you through the two types of functions and provides guidance about how to use them. Also, you can consult examples of how to combines functions to set specific time moments — for example, delivery dates or the time that has elapsed between two specific moments.

Functions for computing time

Computing elapsed time

The following four functions compute the time that has elapsed from 1 January 1970 to a concrete moment in time as specified in the Returns column.

Function Syntax Returns What to Type (example)
timenow() timenow() The current time as counted by your computer. timenow()
timestamp() timestamp(YYYY, MM, DD, HH, MM, SS) For example, the moment 30 days and 3 hours from the current time as counted by your computer. timestamp(2022, 04, 06, 12, 30, 30)
ProjectInfo.Created ProjectInfo.Created The time when a project was created. ProjectInfo.Created
ProjectInfo.LastModified ProjectInfo.LastModified The last time when a project was modified. ProjectInfo.LastModified

Computing a time interval

The following function computes an amount of time — for example, 3 hours and 37 minutes or 5 months and 4 days.

Function Syntax Returns What to Type (example) Result
timespan() timespan(days, hours, minutes, seconds) A set amount of time timespan(3, 2, 20, 15) 3 days, 2 hours, 20 minutes, 15 seconds

Functions for displaying time

IMPORTANT: The two time-displaying functions are what you actually type in the design frame you create.

Displaying elapsed time

Use the timestr() function to convert counted seconds into letters and numbers that you can actually use.

Function Syntax
timestr() timestr(time-computing function, "%attribute1 %attribute2 ... %attributeN")

Displaying time intervals

Use the timespanstr() function to convert the counted seconds of a time interval into letters and numbers that you can actually use.

Function Syntax
timespanstr() timespanstr(time-computing function + timespan(), "%attribute1 %attribute2 ... %attributeN")

The timespanstr() and timestr() functions require attributes to display the time or date in the format that you need.

Formatting attributes

Attribute Where to type it Returns Example Notes
a $timestr(time-computing function, "%a")$ Day of the week, abbreviated Thu Locale dependent
A $timestr(time-computing function, "%A")$ Day of the week, not abbreviated Thursday Locale dependent
b $timestr(time-computing function, "%b")$ Month, abbreviated Feb Locale dependent
B $timestr(time-computing function, "%B")$ Month, not abbreviated February Locale dependent
c $timestr(time-computing function, "%c")$ Current date and time 02/22/2022 11:44:33 Locale dependent
d $timestr(time-computing function, "%d")$ Day of the month 02  
H $timestr(time-computing function, "%H")$ The hour, 24-hour format 13  
I $timestr(time-computing function, "%I")$ The hour, 12-hour format 03  
j $timestr(time-computing function, "%j")$ The day of the year 034  
m $timestr(time-computing function, "%m")$ The month as a numeral 03  
M $timestr(time-computing function, "%M")$ Minute 35  
p $timestr(time-computing function, "%p")$ AM, PM AM  
S $timestr(time-computing function, "%S")$ Second 14  
U $timestr(time-computing function, "%U")$ Week number 14 First Sunday is the first day of week 1
w $timestr(time-computing function, "%w")$ Day of the week as a numeral 4 Sunday is the first weekday, day 0
W $timestr(time-computing function, "%W")$ Week number 14 First Monday is the first day of week 1
x $timestr(time-computing function, "%x")$ Date 08/23/22 Locale dependent
X $timestr(time-computing function, "%X")$ Time 11:34:34 Locale dependent
y $timestr(time-computing function, "%y")$ Year, last two digits 22  
Y $timestr(time-computing function, "%Y")$ Year 2022  
Z $timestr(time-computing function, "%Z")$ Time zone, abbreviated EET Locale dependent

NOTE: When supplying multiple attributes, separate them by a space, like this: $timespanstr(timenow() – ProjectInfo.Created, "%+d %H")$

IMPORTANT: When typing a function's elements, make sure you separate them with your computer's list separator symbol. Yours may be different from the one used here.

Use cases

The following examples show how you can combine time-computing functions to receive practical time-related information, and then use time-displaying functions to display this information.

Setting delivery times

You can combine the timespan() and timenow() functions to specify a moment in the future. Combining the two functions is especially helpful for building expressions for the setting of delivery dates and times.

To set Write
The moment that is 10 days and 4 hours from now $timestr(timenow() + timespan(10,4,0,0), "%c"$

Displaying remaining time

You can combine the timespamp() and timenow() functions to calculate the time that remains to a moment in the future. In the expression, you subtract the current time from the time of a future moment: timestamp()timenow().

The expression is especially useful for computing the time that remains to a delivery.

To set Write
How many days remain to 13 March 2025 $timespanstr(timestamp(2025; 03; 13; 0; 0; 0) - timenow(); "%+d")$

Displaying elapsed time (the time since a file was created or modified)

Use the ProjectInfo.Created and ProjectInfo.LastModified functions to refer to when files were created and modified for the last time, respectively. You can then use these functions to build expressions that compute how long ago a file was created or was last modified.

To calculate Write
How many days and hours ago a project was created. $timespanstr(timenow() – ProjectInfo.Created, "%+d %H")$
How many days and hours ago a project was modified for the last time. $timespanstr(timenow() – ProjectInfo.LastModified, "%+H %M")$