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

后端 未结 3 1678
轮回少年
轮回少年 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:30

    If by "unix time" you mean the epoch second, then Windows doesn't include tools to produce that. Instead, you can install third-party tools. For example:

    • Install Cygwin.
    • Find the date binary (under C:\Cygwin\ or wherever you installed it)
    • Use it as you would in Linux.

    Alternately, per the awesome comment on this answer, you could install GNU Coreutils which also include a date command. It includes a number of other tools that you may not need, but then, so does Cygwin.

提交回复
热议问题