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.

Functions for displaying current date

Function to Use Result Example
$date$ The date as computed by your computer and formatted as per your computer settings. 05-Dec-2023
top of page

Functions for displaying date and time with custom formatting

How it works

To display a time period or a date, EngView 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/formatting 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.
Function Syntax Returns Result Result
Time-computing function timenow() $timenow()$ The number of seconds that have elapsed between 1 January 1970 00:00:00 and the moment the function is called. 1701766510.00
Time formatting function $timestr(timenow(), Attributes)$ $timestr(timenow(), "%d.%m.%Y")$ Displays current time in custom format: DD.MM.YYY 05.12.2023

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.

top of page

Functions for computing time

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

Computing elapsed time

To Type Example
The number of seconds that have elapsed between 1 January 1970 00:00:00 and the moment the function is called. $timenow()$ 1701766510.00
the number of seconds from 1 January 1970 00:00:00 to the moment a file was created. $ProjectInfo.Created$ 1369230724.00
The number of seconds from 1 January 1970 00:00:00 to the last time when a project was modified. $ProjectInfo.LastModified$ 1663166037.00
The number representing the date in the function as the number of seconds from 01 Jan 1970 00:00:00. timestamp(YYYY, MM, DD, HH, MM, SS) / timestamp(2023, 12, 17, 18, 00, 00) 1702828800.00

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.

Pattern

To Compute Syntax
A set amount of time timespan(days, hours, minutes, seconds)

Example

To Compute Type
3 days, 2 hours, 20 minutes, 15 seconds $timespan(3, 2, 20, 15)$
top of page

Functions for displaying and formatting time

Displaying date and time

Use the timestr() function to format counted seconds from 1 January 1970 00:00:00 into a date (letters and numbers) that you can actually use.

Function Use
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 days, hours, minutes and seconds (letters and numbers) that you can actually use.

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

The attributes for formatting

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

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.

top of page

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.

Display current time

What to Type Returns Result
$timestr(timenow(), "%d.%m.%Y")$ Displays current time in custom format: DD.MM.YYY 05.12.2023
$timestr(timenow(), "%Y-%m-%d")$ Displays current time in custom format: YYYY-MM-DD 2023-12-05

Setting a delivery date

You can combine the timenow() and timespan() 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 Result
The moment that is 5 days from now $timestr(timenow()+timespan(5, 0, 0, 0), "%d-%m-%Y")$ 10-12-2023

Displaying remaining time

You can combine the timestamp() 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 Result
How many days remain to 10 December 2023 18:00 $timespanstr(timestamp(2023, 12, 10, 18, 0, 0) - timenow(), "%+d")$ 5
How many days and hours remain to 10 December 2023 18:00 $timespanstr(timestamp(2023, 12, 10, 18, 0, 0) - timenow(), "%+d days and %H hours")$ 5 days and 05 hours
How many hours remain to 10 December 2023 18:00 $timespanstr(timestamp(2023, 12, 10, 18, 0, 0) - timenow(), "%+H")$ 125
top of page

Functions for rounding the computed elapsed time

Rounding down the computed elapsed time

The function displays the number of seconds from 1 January 1970 00:00:00 to the beginning of the current time defined by a precision.

timefloor(time-computing function, precision)

The examples that follow take the current time at: 05.12.2023 14:37:20

Precision Write Returns seconds from 01.01.1970 00:00:00 to Result
y $timefloor(timenow(), "y")$ 01.01.2023 00:00:00 1672524000
m $timefloor(timenow(), "m")$ 01.12.2023 00:00:00 1701381600
d $timefloor(timenow(), "d")$ 05.12.2023 00:00:00 1701727200
H $timefloor(timenow(), "H")$ 05.12.2023 13:00:00 1701777600
M $timefloor(timenow(), "M")$ 05.12.2023 13:46:00 1701779820
S $timefloor(timenow(), "S")$ 05.12.2023 13:46:40 1701779840

Displaying how many seconds are left

timefmod(time-computing function, precision)

The exampes that follow are for current time 05.12.2023 14:37:20

Precision Write Returns seconds from current time to Result
m $timemod(timenow(), "m")$ the beginning of current year (01.01.2023 00:00:00) 1701381600
d $timemod(timenow(), "d")$ the beginning of current month (01.12.2023 00:00:00) 1701727200
H $timemod(timenow(), "H")$ the beginning of current day (05.12.2023 00:00:00) 1701777600
M $timemod(timenow(), "M")$ the beginning of current hour (05.12.2023 14:00:00) 1701779820
S $timemod(timenow(), "S")$ the beginning of current minute (05.12.2023 14:37:00) 1701779840
top of page