Hour and minute from unixtime

Posted By: Grat

Hour and minute from unixtime - 06/04/19 12:36

Hi,

i get from outside source data with timestamp in the unixtime.
Code:
uTime = "1559651639";
// convert to time
dTime=wdatef("t",uTime);



Q: how to get minute and hour from uTime?

I found only this:

atoi(strdate("%H",dTime));

for hour


Thanks
Posted By: jcl

Re: Hour and minute from unixtime - 06/05/19 05:32

C puzzle: How do you get minute and hour from dTime without string conversion? Solution in the next days.
Posted By: jcl

Re: Hour and minute from unixtime - 06/07/19 13:49

No takers...

Hour = (int)((dTime-floor(dTime))*24);
Minute = (int)((dTime-floor(dTime))*1440) % 60;
Posted By: Grat

Re: Hour and minute from unixtime - 06/07/19 14:33

laugh


// define
#define Date2Hour(dt) (int)((dt-floor(dt))*24)

use:

Hour = Date2Hour( var );
© 2024 lite-C Forums