How to convert DINT value to dateTime in archestra wonderware

Hi everyone,

I have a value that needs to be converted to datetime. The timestamp store in RSLogix 5000 is in DINT value and I need to use that value and convert in into datetime in archestra wonderware. How to do it??

Screenshot 2024-10-16 105052.pngScreenshot 2024-10-16 105212.png
 
A UNIX timestamp, also known as UNIX epoch time, represents the number of seconds elapsed since January 1, 1970, to the current date. Converting epoch time can be achieved through various libraries available in different programming languages, such as datetime or time functions.

If you are looking for conversion logic, here you go...

Conversion Logic:

1. Divide the total seconds by 60 - the remainder provides the seconds.

2. Divide the quotient from the previous step by 60 - the remainder gives minutes.

3. Divide the quotient again by 24 - the remainder provides the hour in 24-hour format.

4. Further divide the quotient by 365 (assuming 365 days in a year).

5. Divide the new quotient by 4 - if the quotient is less than the remainder from the previous step, consider it as the number of years. If greater, subtract one from the quotient.

6. Add the resulting years to 1970.

7. Subtract the quotient from step 5 from the remainder obtained in step 4.

8. If the remainder from step 5 is 2 and the remainder from step 4 is less than 59, add 1. This becomes the day of the year.

9. Calculate the month and date based on the day of the year, assuming each month has 30 days. Use remainder and quotient values to identify the month and date.

Following these steps will yield the date and time in a proper format.
 
Top