devilyn Posted January 7, 2010 Posted January 7, 2010 all, i trying to parse an xml from a third party tool that extract an odd file date sting value "1184380538000" that somehow translate to "Saturday, April 12, 2008 15:40:22" the original JS parsing funciton is: function DateToString(dateDate) { var strRet; if (dateDate.valueOf()) strRet = dateDate.toDateString() + " " + dateDate.toLocaleTimeString(); else strRet = ""; return strRet; } any idea? thanks in advance Lior.
PsaltyDS Posted January 7, 2010 Posted January 7, 2010 Javascript's basic time unit appears to be milliseconds since 01/01/1970 ("The Computer Epoch"). This gives "2007/07/14 02:35:38": #Include <Date.au3> $n = 1184380538000 ConsoleWrite("$n = " & $n & @LF) $sTime = _DateAdd("s", Int($n / 1000), "1970/01/01 00:00:00") ConsoleWrite("$sTime = " & $sTime & @LF) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Malkey Posted January 8, 2010 Posted January 8, 2010 If you know a date value equals a particular date and time. Then this function will calculate a date and time from a date value. This method will only work when the date value is the number of milliseconds from a specific date and time. #include <Date.au3> Local $sNewDate Local $ThenknownDateValue = 1184380538000 + 3600000 ; 3,600,000 milliseconds = 1 hr DateConvertFromKnownConversion(1184380538000, "2008/04/12 15:40:22", $ThenknownDateValue, $sNewDate) MsgBox(0, "Conversion", $ThenknownDateValue & " converts to " & $sNewDate) Func DateConvertFromKnownConversion($IfThisDateValue, $EqualsThisDate, $ThenknownDateValue, ByRef $EqualsUnknownDate) Local $CalcTime, $hGui, $idDate $CalcTime = _DateAdd("s", Int(($ThenknownDateValue - $IfThisDateValue) / 1000), $EqualsThisDate) ;Format date $hGui = GUICreate("") $idDate = GUICtrlCreateDate($CalcTime, 10, 10) GUICtrlSendMsg($idDate, 0x1032, 0, "dddd, MMMM d, yyyy HH:mm:ss"); or "hh:mm tt" $EqualsUnknownDate = GUICtrlRead($idDate) GUIDelete($hGui) EndFunc ;==>DateConvertFromKnownConversion
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