what is the windows equivalent of the command “date+%s”

后端 未结 3 1647
轮回少年
轮回少年 2021-01-19 07:52

I\'m writing a batch script and I need the unix time. It\'s easy under linux, but I can\'t figure out how to do this in windows.

3条回答
  •  情话喂你
    2021-01-19 08:22

    You can use vbscript in windows, the interpreter is available on your system.

    '--------------------epoch.vbs----------------------- 
    option explicit
    dim s,o,z
    for each o in GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem")
    z=o.CurrentTimeZone
    next
    s=DateDiff("s", "01/01/1970 00:00:00", Now())-(60*z)
    wscript.echo(s)
    wscript.quit
    

提交回复
热议问题