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

Just starting out? Need help? Post your questions and find answers here.
wimapon
Enthusiast
Enthusiast
Posts: 290
Joined: Thu Dec 16, 2010 2:05 pm
Location: Delfzijl ( The Netherlands )
Contact:

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

Post 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
User avatar
Kiffi
Addict
Addict
Posts: 1504
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

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

Post 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
Hygge
wimapon
Enthusiast
Enthusiast
Posts: 290
Joined: Thu Dec 16, 2010 2:05 pm
Location: Delfzijl ( The Netherlands )
Contact:

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

Post by wimapon »

ho Kiffy
so that is a very quick response,
i go try it.
thank you very much

Wim
wimapon
Enthusiast
Enthusiast
Posts: 290
Joined: Thu Dec 16, 2010 2:05 pm
Location: Delfzijl ( The Netherlands )
Contact:

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

Post 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
Post Reply