Forum Discussion

akuczkowski's avatar
akuczkowski
Contributor
9 years ago

Anyone know how to get Unix Time using DelphiScript?

I need the current datetime formatted as Unix time (the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970). Anyone know how to get that value? We are using TestComplete 11 and DelphiScript.

 

Thanks,

Adam

  • Sorry to answer my question, but it turned out this was easy to calculate using TestComplete DateTime methods.

     

    iUnixTimeInDays := aqConvert.VarToFloat(aqDateTime.TimeInterval(Now(), aqDateTime.SetDateTimeElements(1970,1,1,0,0,0)));
    iUnixTimeInSeconds := iUnixTimeInDays * 24 * 60 * 60;

  • Sorry to answer my question, but it turned out this was easy to calculate using TestComplete DateTime methods.

     

    iUnixTimeInDays := aqConvert.VarToFloat(aqDateTime.TimeInterval(Now(), aqDateTime.SetDateTimeElements(1970,1,1,0,0,0)));
    iUnixTimeInSeconds := iUnixTimeInDays * 24 * 60 * 60;