Forum Discussion
- HKosovaSmartBear Alumni (Retired)Hi Nassim,
Try this:
var unixTime = Math.round((new Date()).getTime() / 1000);
Set dtUTC = GetObject("winmgmts:\\.\root\cimv2:Win32_UTCTime=@")
dt = aqDateTime.SetDateTimeElements(dtUTC.Year, dtUTC.Month, dtUTC.Day, dtUTC.Hour, dtUTC.Minute, dtUTC.Second)
unixTime = DateDiff("s", "01/01/1970 00:00:00", dt) - nassimOccasional ContributorHi Helen,
Thank you very much for your help. Once, the VM windows time showsed 10:48 and I ran your solution like this:
Set dtUTC = GetObject("winmgmts:\\.\root\cimv2:Win32_UTCTime=@")
dt = aqDateTime.SetDateTimeElements(dtUTC. Year, dtUTC.Month, dtUTC.Day, dtUTC.Hour, dtUTC.Minute, dtUTC.Second)
curTimeStr = aqConvert.DateTimeToStr(dt)
Log.Message("current time is " & curTimeStr)
unixTime = DateDiff("s", "01/01/1970 00:00:00", dt)
Log.Message("unix time is " & unixTime)
in Log I see:
current time is 04.10.2011 08:48:37
unix time is 1317718117
As I checked the unix time 1317718117 , it relates to the date
Tue Oct 04 10:48:37 2011
I am confused. It would be very kind if you or another member can help.
Thank you in advance
Nassim - HKosovaSmartBear Alumni (Retired)Hi Nassim,
Your computer is set to the GMT+2 time zone, right?
The VBScript code that I posted uses the UTC/GMT time, so the lines that you added:
report the UTC/GMT time rather than your local time, hence the two-hour time difference.
curTimeStr = aqConvert.DateTimeToStr(dt)
Log.Message("current time is " & curTimeStr)
To log your local time, use the following code instead:
Check out these links for more information:
http://www.epochconverter.com/epoch/timezones.php?epoch=1317718117
http://www.timestampgenerator.com
Related Content
- 9 years ago
- 5 years ago
Recent Discussions
- 2 days ago
- 2 days ago
- 5 days ago