Home

Download project

Date and Time

The example shows how to use the date and time functions of the SysTime and Util libraries.

Product description

The project contains examples on the following topics:

  • Reading timer tick values since system startup
  • Read UTC time
  • Convert UTC time to local time
  • Local time and time zone operations

More information

In the visualization placeholders e.g. "%t[ddd MMM dd.MM.yyyy HH:mm:ss]" are used to display the current system time.
The displayed format can be modified with placeholders shown below.
See also the CoDeSys Online Help under
https://content.helpme-codesys.com/en/CODESYS%20Visualization/_visu_placeholder_with_formatting_sequence_in_a_string.html

Placeholder Date and time formats
ddd Name of weekday, abbreviated, e.g. "Wed"
dddd Name of weekday, e.g. "Wednesday"
ddddd Weekday as decimal number (0-6, Sunday is 0)
MMM Name of month, abbreviated, e.g. "Feb"
MMMM Name of month, e.g. "February"
d Day of month as number (1-31), e.g. "8"
dd Day of month as number (01-31), e.g. "08"
M Month as number (1-12), e.g. "4"
MM Month as number (01-12), e.g. "04"
jjj Day of the year as number (001-366), e.g. "067"
y Year without specification of century (0-99), e.g."9"
yy Year without specification of century (00-99), e.g. "09"
yyy Year with specification of century, e.g. "2009"
HH Hour, 24-hours format (01-24), e.g. "16"
hh Hour, 12-hours format (01-12), e.g. "4" for 16 o'clock
m Minutes (0-59), without preceded zero, e.g. "6"
mm Minutes (00-59), with preceded zero, e.g. "06"
s Seconds (0-59), without preceded zero, e.g. "6"
ss Seconds (00-59), with preceded zero, e.g. "06"
ms Milliseconds (0-999), without preceded zero, e.g. "322"
t "A/P" identifier for 12-hours format: "A" for hours < 12, "P" for hours > 12; e.g. "A" for 9 o'clock in the morning
tt "AM/PM" identifier for 12-hours format: "AM" for hours < 12, "PM" for hours > 12, e.g. "AM" for 9 o'clock in the morning
' ' Text strings containing one of the placeholders listed above must be put in single quotation marks; all other text within the format string can be used without quotation marks. e.g. 'update' because of "d" and "t"

System requirements and restrictions

System requirements and restrictions Info
Programming System CODESYS Development System Version 3.5.14.0 or higher
Runtime System CODESYS Control Version 3.5.14.0
Required Accessories -