Page 1 of 1

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

Posted: Tue Jul 03, 2018 3:43 am
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

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

Posted: Tue Jul 03, 2018 5:00 am
by SergeyK
time t;
t=makeTime(1999,8,18,12,00);


Look up for "Time functions" in help.

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

Posted: Tue Jul 03, 2018 8:57 am
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