Page 1 of 1

i need a simple routine to convert unix-time to date-time

Posted: Tue Mar 19, 2024 11:17 am
by wimapon
Hi folks,
I need a simple routine to convert unix date-time to a date and time notation.
Unix date-time is the number of seconds since 1-1-1970.
so this amount of seconds must be changed in a date like 28-03-2024 and 12hours and 25 seconds ( as an example)

i can calculate date to unix time, but the other way around not.
so the date 15 march 2014 0 hours and 0 minutes gives 1394928000 seconds.

so please who can help me.
please no stuctures and other fancy tricks....just a few pure basic lines.. an input and an output.


by the way,, i do use purebasic now for a lot of years and am very happy with it!

Wim Apon

Re: i need a simple routine to convert unix-time to date-time

Posted: Tue Mar 19, 2024 11:24 am
by Kiffi

Code: Select all

UnixTime = 1394928000

Debug FormatDate("%dd.%mm.%yyyy %hh:%ii", UnixTime)

BTW: It's the 16 march 2014 0 hours and 0 minutes

Re: i need a simple routine to convert unix-time to date-time

Posted: Tue Mar 19, 2024 11:31 am
by wimapon
ho Kiffy
so that is a very quick response,
i go try it.
thank you very much

Wim

Re: i need a simple routine to convert unix-time to date-time

Posted: Tue Mar 19, 2024 11:41 am
by wimapon
Hi Kiffy,
again...it works like a charm.
i also found now the date command for the other way around.
It is much faster than my old program... that program used 36 lines of code.....

again, thank you very much

Wim