The VBS does not have a time function similar to the C standard library, how do I get a unix timestamp? At first glance it's simple:
Copy Code code as follows:
Function Unixtime ()
Unixtime = DateDiff ("s", "01/01/1970 00:00:00", Now ())
End Function
A way to take it for granted, only to notice "January 1, 1970 0:0 0 Seconds", but ignored the "coordinated world time."
Coordinated world, also known as world standard Time or world coordination time, referred to as UTC, from the English "Coordinated Universal times". local time in mainland China is 8 hours faster than UTC, writing utc+8. If the local time is slower than the UTC time, such as Hawaii time is 10 hours slower than UTC time, will write UTC-10.
The now () function in the VBS returns a time that includes time zones, so there are some corrections to getting the Unix timestamp.
Copy Code code as follows:
Function Unixtime ()
Set objWMIService = _
GetObject ("winmgmts:\\.\root\cimv2")
Set Colitems = objWMIService.ExecQuery _
("SELECT * from Win32_OperatingSystem", 48)
For each objitem in colitems
TimeZone = Objitem.currenttimezone
Next
Unixtime = DateDiff ("s", "01/01/1970 00:00:00", Now ())
Unixtime = Unixtime-timezone * 60
End Function
This is the right way to spell.
Reference Links:
Epoch & Unix Timestamp conversion Tools
Original: http://demon.tw/programming/vbs-unix-time-stamp.html