Is there a library of time manipulation functions available for use?

Find and share HowTos to various installations / configurations!
Search

Post Reply
3 posts • Page 1 of 1
AngusETM
Posts: 37
Joined: Tue Apr 25, 2017 4:48 pm

Is there a library of time manipulation functions available for use?

Post by AngusETM »

Hi all,


We have a requirement to manipulate some time variables. For example, add or subtract seconds, minutes, hours, days, months or years from a given time.

We've looked through the built in time functions and have not found functions which do this pre-existing.

Has anyone written a time library to handle these tasks available for use?


Kind regards,

Angus Heyworth

SergeyK
Posts: 12
Joined: Wed Nov 02, 2016 12:03 pm

Re: Is there a library of time manipulation functions available for use?

Post by SergeyK »

time t;
t=makeTime(1999,8,18,12,00);


Look up for "Time functions" in help.

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

Re: Is there a library of time manipulation functions available for use?

Post by leoknipp »

A time variable in WinCC OA is an analog value counting the seconds since 1970.01.01 00:00.
If you want to modify the time you can do this by mathematical operations.
E.g. adding 10 seconds to a given time.

time tValue;

// read the current time
tValue = getCurrentTime();

// add 10 seconds (as integer value)
tValue = tValue + 10;

Doing mathematical operations is also possible with variables of type "time".
E.g. getting the difference between two times;

time t1, t2;
float fDiff;

t1 = getCurrentTime();
delay(5,5);
t2 = getCurrentTime();

fDiff = t2 - t1;

Best Regards
Leopold Knipp
Senior Support Specialist

Post Reply
3 posts • Page 1 of 1