Hi
I have soap request coming back with the element called Expirydate which send me the Date(151467840000+00 ...... )?
i want to read this as date, can you help please?
Thanks
Convert Unix Time to Date
Re: Convert Unix Time to Date
Hello,
this is the way to create such a UNIX date, you can convert it back the same way. IsLeap() is a TOOLS III Function
regards
Rudolf
this is the way to create such a UNIX date, you can convert it back the same way. IsLeap() is a TOOLS III Function
regards
Rudolf
Code: Select all
*******************
Function DateAsSecs( _dDate )
*******************
Local nDays := 0
Local nSecs := 0
Local dStartDate := CToD( '01.01.1970' )
Local nStartDate := 1970
Local nYear := Year( _dDate )
Local nDoY := DoY( _dDate )
Local nDaysSecs := ( nDoY * 86400 )
Local i
For i := nStartDate To nYear
If IsLeap( CToD( '01.01.' + Str( i, 4 ) ) )
nDays += 366
Else
nDays += 365
EndIf
Next
nSecs := ( nDays * 86400 )
nSecs += nDaysSecs
Return ( nSecs )
Re: Convert Unix Time to Date
Hi,
If you just need the date:
ctod("01/01/70") + int(1514678400/86400) will give the date.
In this case the result is: 31/12/2017.
To calculate your unix date string.
(date()- ctod("01/01/70")) * 86400
If you just need the date:
ctod("01/01/70") + int(1514678400/86400) will give the date.
In this case the result is: 31/12/2017.
To calculate your unix date string.
(date()- ctod("01/01/70")) * 86400
Re: Convert Unix Time to Date
Thank you very much for your replies, Rudolf and Chris
Chris's code works perfect.
Thanks
Pandya
Chris's code works perfect.
Thanks
Pandya