lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




Am 28.03.2017 um 12:32 schrieb Javier Mr:

Hi,

I'm having a little bit of trouble converting dates in UTC to timestamps and back to dates.

I obtain the ITC timestamp as os.time( os.date( "!*t" ) ); back when converting it back to date doesn't matter is I use "!*t" or "*t"; I always get the hour wrong, either one hour less or one hour more.

I  link the SO question which I have post.

Regards.

Javier

Hi.

os.time() normally operates on local time. I usually apply a correction:

utc = os.time{ ...some table ...} - os.time{year=1970, month=1, day=1, hour=0}

which subtracts the offset to local time.

--
Oliver