Sign in to follow this  
Followers 0
JonnyThunder

Date / Time stamp (unix style)

3 posts in this topic

Ello,

I'm using this function to create a unix style integer time stamp (seconds since 1/1/1970).

Can anyone tell me how to do the reverse of this function??

Thanks,

ConsoleWrite ( nowtime () )
; returns 1208771333

Func nowtime ()
    return _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc())
EndFunc

Share this post


Link to post
Share on other sites



Hi,

#include <Date.au3>
Global $re = nowtime()
ConsoleWrite($re & @CRLF)
ConsoleWrite(_DateAdd('s', -$re, _NowCalc()) & @CRLF)

Func nowtime()
    Return _DateDiff('s', "1970/01/01 00:00:00", _NowCalc())
EndFunc   ;==>nowtime

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ahh never mind. Figured it out.

Just in case anyone else likes storing date/time as integer - here's the functions....

; Function to return current time in integer format
Func nowtime ()
    return _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc())
EndFunc


; Function to return date from an unix style integer timestamp
Func datefromint ( $intime )
    return _DateAdd ( 's', $intime, "1970/01/01 00:00:00" )
EndFunc

EDIT: Ahh, you just beat me to it! :-)

Edited by JonnyThunder

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0