Home » Questions » Computers [ Ask a new question ]

Windows analog to unix time command

Windows analog to unix time command

What is the windows analog to unix time command?

Asked by: Guest | Views: 29
Total answers/comments: 1
Guest [Entry]

"Through my own research online, I was not able to find a way to do this via a batch file directly. However, I was able to find this solution that worked for me:

In toEpoch.vbs:

WScript.Echo DateDiff(""s"", ""01/01/1970 00:00:00"", Now())

Then called from my batch script like so:

for /f ""delims="" %%x in ('cscript /nologo filename.vbs') do set epoch=%%x

That set the %epoch% variable with the current unix timestamp and I was able to use it as I needed to.

Hope this helps."