<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/</id><updated>2024-01-05T09:40:55.597000Z</updated><subtitle>Recent posts to System Date and Time Function</subtitle><entry><title>System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/?limit=25#0824" rel="alternate"/><published>2024-01-05T09:40:55.597000Z</published><updated>2024-01-05T09:40:55.597000Z</updated><author><name>atone</name><uri>https://forge.codesys.com/u/atone/</uri></author><id>https://forge.codesys.com371a0efc49aff8806a0a6c69bb3e8d5261ee900b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;SysTimeRtcConvertUtcToLocal is marked as obsolete, but there's not hint on the actual implementation. Which function should I use instead?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/?limit=25#7404/08c7" rel="alternate"/><published>2021-09-23T02:08:50.763000Z</published><updated>2021-09-23T02:08:50.763000Z</updated><author><name>zawadzki666</name><uri>https://forge.codesys.com/u/zawadzki666/</uri></author><id>https://forge.codesys.comabde4708ab61b43ca4603033e35da8c8d9d57bdc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Imendez&lt;br/&gt;
In my case, using the PLC_TIME function, my time is delayed by 2 hours to the system time. Why is this happening? Everything is ok when the offset is set to 120. What are the input variables for in this function of time and year?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/?limit=25#652c/dd9b" rel="alternate"/><published>2021-09-22T23:54:47.324000Z</published><updated>2021-09-22T23:54:47.324000Z</updated><author><name>zawadzki666</name><uri>https://forge.codesys.com/u/zawadzki666/</uri></author><id>https://forge.codesys.com3d59f5d3f1b4e3f0d21e8c7769c60099a69a8cad</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Edwin,&lt;br/&gt;
In which library can I find this FB? I am user of Codesys 3.5.17&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/?limit=25#f09f" rel="alternate"/><published>2020-02-27T13:56:32.666000Z</published><updated>2020-02-27T13:56:32.666000Z</updated><author><name>lefrank01</name><uri>https://forge.codesys.com/u/lefrank01/</uri></author><id>https://forge.codesys.com3b0311b94be1aacd9fff73acab8d088ce45c5f1b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;hi, I'm new user of Codesys and when I import the POU for time, this POU doesnt appear to be a fonction block, does someone can help me?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/?limit=25#7404" rel="alternate"/><published>2020-02-27T13:56:32.452000Z</published><updated>2020-02-27T13:56:32.452000Z</updated><author><name>lmendez</name><uri>https://forge.codesys.com/u/lmendez/</uri></author><id>https://forge.codesys.comccfb5aeec50b9c185cd365da74f5cd0bc28ab32e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks Edwin and jzhvymetal for your prompt feedback,&lt;/p&gt;
&lt;p&gt;I have decided to go with the following set of instructions,&lt;/p&gt;
&lt;p&gt;VAR&lt;br/&gt;
              Date_and_time_in_seconds  : UDINT;&lt;br/&gt;
    Local_date_time_seconds : UDINT;&lt;br/&gt;
    Date_and_Time_result    : UDINT;&lt;br/&gt;
    Local_date_time_from_secs   : SYSTIMEDATE;&lt;br/&gt;
    Date_and_time_format    : DATE_AND_TIME;&lt;br/&gt;
    Date_and_time_string    : STRING;&lt;/p&gt;
&lt;p&gt;END_VAR&lt;/p&gt;
&lt;p&gt;// Get time in seconds since 1970 :&lt;br/&gt;
Date_and_time_in_seconds := SysTimeRtcGet(Date_and_Time_result);&lt;br/&gt;
IF Date_and_Time_result &amp;lt;&amp;gt; 0 THEN&lt;br/&gt;
    RETURN;&lt;br/&gt;
END_IF&lt;/p&gt;
&lt;p&gt;// Convert UTC seconds to local time seconds, regarding Timezone and Summer time :&lt;br/&gt;
Date_and_Time_result := SysTimeRtcConvertUtcToLocal(Date_and_time_in_seconds, Local_date_time_seconds);&lt;br/&gt;
IF Date_and_Time_result &amp;lt;&amp;gt; 0 THEN&lt;br/&gt;
    RETURN;&lt;br/&gt;
END_IF&lt;/p&gt;
&lt;p&gt;// Convert the UTC seconds to a DATE_AND_TIME variable dt#yyyy-mm-dd-hh:mm:ss :&lt;br/&gt;
Date_and_time_format := UDINT_TO_DT(Local_date_time_seconds);&lt;/p&gt;
&lt;p&gt;// Convert DATE_AND_TIME to a String :&lt;br/&gt;
Date_and_time_string := DT_TO_STRING(Date_and_time_format);&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/?limit=25#6548" rel="alternate"/><published>2020-02-27T13:56:32.245000Z</published><updated>2020-02-27T13:56:32.245000Z</updated><author><name>jzhvymetal</name><uri>https://forge.codesys.com/u/jzhvymetal/</uri></author><id>https://forge.codesys.comebc6e6a7427dba08199a538781ffb942b284010d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Try the following POU&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: PLC_TIME_V2.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1220"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://forum.codesys.com//download/file.php?id=1221" rel="nofollow"&gt;PLC_Time_V2.zip &lt;span&gt;&lt;span&gt;[3.26 KiB]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/?limit=25#652c" rel="alternate"/><published>2020-02-27T13:56:32.033000Z</published><updated>2020-02-27T13:56:32.033000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.comb7e2fd09ef7f47dda5c9eaf94f27bda37e8deee4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
you are right i agree ... we will change either this Date and Time example (add an simple fb)&lt;br/&gt;
or we need to add an FB to a library which bring a simple (visu like) result.&lt;br/&gt;
BR&lt;br/&gt;
Edwin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/?limit=25#274d" rel="alternate"/><published>2020-02-27T13:56:31.822000Z</published><updated>2020-02-27T13:56:31.822000Z</updated><author><name>lmendez</name><uri>https://forge.codesys.com/u/lmendez/</uri></author><id>https://forge.codesys.com93925afc1620db1e612b7a0702e4730fc33bb741</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Perhaps I shall add that I am writing a CoDeSys application to run through Win SL that is expected to go in a product that could be in any timezone. (It actually might travel through several timezones)&lt;/p&gt;
&lt;p&gt;This is the reason why I would like to understand if there is a method to obtain the computer's system time by just by requesting it.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>System Date and Time Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4749e14b77/?limit=25#3c31" rel="alternate"/><published>2020-02-27T13:56:31.162000Z</published><updated>2020-02-27T13:56:31.162000Z</updated><author><name>lmendez</name><uri>https://forge.codesys.com/u/lmendez/</uri></author><id>https://forge.codesys.com8a4795dc92b2384530dee735ee5b29846e34857a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Is there a more direct method to extract the current PC's system date and time in Structured Language for a CoDeSys application?&lt;/p&gt;
&lt;p&gt;I have tried the two methods implemented in the DateTimeUtilities example but I honestly believe that there should be an easier way to interrogate the system to obtain the present date and time without the need to have the program to invest time in calculating dates and times from 1970 and expecting a parameter for the timezone. The System's date and time is already available in the PC.&lt;/p&gt;
&lt;p&gt;I have also attempted the RTC function, but this method requires the timezone parameter also.&lt;/p&gt;
&lt;p&gt;In contrast, in the visualization the direct exhibition of a text like %t&lt;span&gt;[ddd MMM.dd.yyyy  HH:mm:ss]&lt;/span&gt; in a text field will display Thu Jun.25.2015  18:22:14 at running time - easy, clear and direct.&lt;/p&gt;
&lt;p&gt;Luis Mendez&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>