Jump to content
Sign in to follow this  

Parsing an odd Date string.

Recommended Posts



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();
        strRet = "";
    return strRet;

any idea?

thanks in advance


Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

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)
EndFunc ;==>DateConvertFromKnownConversion

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.