TIA Portal: Unified Comfort Panel: How to add Local Date and Time with Script

robototem
2 min readNov 4, 2022

The simplest way to show your date and time in your Unified Comfort Panel is just writing one line of code.

1- Create “Text Box”

Create two “Text Box” from the toolbox, one for the date and one for the time.

2. Add “Script” property your Text

Click on the Text Box > Go to its properties > Next to “Text” select “Script” from dropdown menu.
If you don´t see script page on the right side, click small arrow to the left and open the script area.

3. Write your Magic Script

To show the Date just add the following code, declaring your region for example: ´de-DE´ for Germany.

For Local Date:

value = new Date().toLocaleDateString('de-DE');

For Local Time:

value = new Date().toLocaleTimeString('de-DE');

For your region, just check “ISO Language Code Table” under this link:

Language Code Table (lingoes.net)

If the Time or Date is Displayed Wrong

What if Unified Panel does not show the right time that you expected? There could be time difference because of your settings.

Under your PLC properties, go to Time of Day and set your local time and format.

Also one more thing:

After you connect to your PLC, go to “Online & Diagnostics” and under “Set Time”, APPLY your computer time to your PLC! So both can have the same date and time.

Congratulations! Your date and time are updated!

If you have found this post useful, make sure to follow me on Medium :)

--

--

robototem

TIA Portal, Image Processing, Engineering, and my favorite topics