therks Posted August 21, 2005 Posted August 21, 2005 (edited) * Aug 22 - Update to TimeMakeStamp function, now accepts default keyword for last param. So, a while ago I asked Valik what the possibilty to implement some of the functions I'm used to in PHP might be. He pointed out that they were available through some Dll calls, and so I created these UDFs. Big thanks to him for the pointers and the help he provided.The zip has the include file, examples for each function, and the text files for creating help documents for each function. Quote AutoIt Version: 3.1.1++ Language: English Description: Dll wrapper functions for dealing with Unix timestamps. Requirement(s): CrtDll.dll Notes: If CrtDll.dll is not available then functions will return false and set @error = 99. Functions:_TimeGetStamp - Get current time as Unix timestamp value. Like the PHP time function. -----_TimeMakeStamp - Create Unix timestamp from input values. Syntax: _TimeMakeStamp( [ second [, minute [, hour [, day [, month [, year [, isDST ]]]]]]] ) Like the PHP mktime function. -----_StringFormatTime - Get a string representation of a timestamp according to the format string given to the function. Syntax: _StringFormatTime( "format" [, timestamp [, max length ]] ) Like the PHP strftime function. I'm in the process of duplicating PHP's date function as well. Like Valik pointed out, it's mostly just a wrapper for strftime anyway. Anyway, enjoy, hope somebody finds these useful. -----Edit: The broken URL was brought to my attention via email. I don't have it in a zip with examples, but the .au3 file is available at the above link. Edit 2: Again the URL has been broken for a while, and again brought to my attention via email. The URL has been updated. Edit 3: Broken URL called to my attention again. Adding the file to this thread. Don't know why I didn't do this sooner. UnixTime.au3 Edited August 4, 2016 by therks Broken URL genius257 1 My AutoIt Stuff | My Github
therks Posted August 23, 2005 Author Posted August 23, 2005 Using these functions, I created this application. expandcollapse popup#NoTrayIcon #include <GuiConstants.au3> #include <UnixTime.au3> $s_DefMakeString = '%#S, %#M, %#H, %#d, %#m, %Y' $i_StampNow = _TimeGetStamp() $s_MakeStamp = _StringFormatTime($s_DefMakeString, $i_StampNow) $s_Value = _StringFormatTime('%#c', $i_StampNow) #region - GUI $gui_Main = GuiCreate('TimeStamp Tool', 265, 105) $bt_Get = GuiCtrlCreateButton('&Get current values for all fields', 5, 5, 255, 20) GuiCtrlCreateLabel('&Timestamp: ', 5, 30, 70, 20, $SS_CENTERIMAGE) $in_Stamp = GuiCtrlCreateInput($i_StampNow, 75, 30, 130, 20) $bt_Use = GuiCtrlCreateButton('&Use', 210, 30, 50, 20) GuiCtrlCreateLabel('Make &Stamp: ', 5, 55, 70, 20, $SS_CENTERIMAGE) $in_MakeStamp = GuiCtrlCreateInput($s_MakeStamp, 75, 55, 130, 20) $bt_Make = GuiCtrlCreateButton('&Make', 210, 55, 50, 20) $in_Value = GuiCtrlCreateInput($s_Value, 5, 80, 255, 20, $ES_READONLY) #endregion GuiSetState() While 1 $gm = GuiGetMsg() Select Case $gm = $bt_Use $i_Stamp = GuiCtrlRead($in_Stamp) $s_MakeStamp = _StringFormatTime($s_DefMakeString, $i_Stamp) $s_Value = _StringFormatTime('%#c', $i_Stamp) GuiCtrlSetData($in_MakeStamp, $s_MakeStamp) GuiCtrlSetData($in_Value, $s_Value) Case $gm = $bt_Make Dim $a_MakeParams[7] = [ default, default, default, default, default, default, default ] $s_MakeString = StringStripWS(GuiCtrlRead($in_MakeStamp), 8) $ai_MakeSplit = StringSplit($s_MakeString, ',') For $i = 1 to $ai_MakeSplit[0] $a_MakeParams[$i - 1] = $ai_MakeSplit[$i] Next $i_Stamp = _TimeMakeStamp($a_MakeParams[0], $a_MakeParams[1], $a_MakeParams[2], $a_MakeParams[3], $a_MakeParams[4], $a_MakeParams[5], $a_MakeParams[6]) $s_Value = _StringFormatTime('%#c', $i_Stamp) GuiCtrlSetData($in_Stamp, $i_Stamp) GuiCtrlSetData($in_Value, $s_Value) Case $gm = $bt_Get $i_StampNow = _TimeGetStamp() $s_MakeString = _StringFormatTime($s_DefMakeString, $i_StampNow) $s_Value = _StringFormatTime('%#c', $i_StampNow) GuiCtrlSetData($in_Stamp, $i_StampNow) GuiCtrlSetData($in_MakeStamp, $s_MakeString) GuiCtrlSetData($in_Value, $s_Value) Case $gm = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd My AutoIt Stuff | My Github
OverloadUT Posted June 28, 2006 Posted June 28, 2006 Thank you!! I was ripping my hair out trying to figure out a good way to generate a Unix timestamp, but I totally forgot to search Scripts and Scraps! These functions work perfectly.
Max Kipness Posted April 13, 2008 Posted April 13, 2008 Hi - Does anybody happen to have this UnixTime.zip file. I need to convert a unix time/date stamp to a string date. The link that was posted in 2006 doesn't seem to work anymore. Thanks, Max
Xenobiologist Posted April 13, 2008 Posted April 13, 2008 Hi, post in support. String before String after 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
-Ultima- Posted April 13, 2008 Posted April 13, 2008 http://www.therks.com/autoit/udfs/You'll find Saunder's UDFs there. [ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]
therks Posted June 19, 2013 Author Posted June 19, 2013 Updated first post with new URL. My AutoIt Stuff | My Github
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now