-->
Page 1 of 2

Get Time between period of time.

PostPosted: Mon Jan 11, 2021 3:29 pm
by BLCKPSTV
Hi,

I hope I picked the correct subchannel for this question.

I have a project that runs for 2 or 3 weeks.
When the project runs I want an Wemos D1 mini chip to get it's current day of running the code (even when it needs to be rebooted preferably, but this is not necessary).
Until the 2 or 3 weeks have been done.

Later on I want to send the current day to another program via osc.

How do I do this? There are a lot of get_time options but most of them just calculate time in a year. I just niet days of a certain amount of time.

Re: Get Time between period of time.

PostPosted: Mon Jan 11, 2021 4:00 pm
by schufti
in general time() returns unix time=seconds since 1.1.1970
so if you read time() @ start of your operation and subtract it from time() @ any later moment it is just plain arithmetics to calculate d/h/m/s from this difference...

if it dosn't have to be consistent over reboot you can use millis(), it is sufficient for about 50days after reboot.

Re: Get Time between period of time.

PostPosted: Mon Jan 11, 2021 4:19 pm
by BLCKPSTV
Hmmm :? my arithmatics aren't that good I guess...

I'm reading up on the time() and the epochs stuff. But how do I state day one and add days with this.

sorry probably easy but not seeing it atm..

Re: Get Time between period of time.

PostPosted: Mon Jan 11, 2021 4:21 pm
by BLCKPSTV
BLCKPSTV wrote:Hmmm :? my arithmatics aren't that good I guess...

I'm reading up on the time() and the epochs stuff. But how do I state day one and add days with this.

sorry probably easy but not seeing it atm..



I'll look in to the millis() first that I understand for the moment :D