Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:12:59+00:00 2026-06-07T07:12:59+00:00

For all I know, Batch does not have a command that gives the UNIX

  • 0

For all I know, Batch does not have a command that gives the UNIX time. The closest one I can find is %time%, which only displays the timestamp.

Is there a command, or set of commands in Batch with which you can get the UNIX time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:13:01+00:00Added an answer on June 7, 2026 at 7:13 am

    There’s Richie Lawrence’s batch library that has all those nifty handy scripts. The one you need is DateToSec (which uses GetDate and GetTime).

    Here’s a simplified script, that employs a little WMI:

    @echo off
    setlocal
    call :GetUnixTime UNIX_TIME
    echo %UNIX_TIME% seconds have elapsed since 1970-01-01 00:00:00
    goto :EOF
    
    :GetUnixTime
    setlocal enableextensions
    for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do (
        set %%x)
    set /a z=(14-100%Month%%%100)/12, y=10000%Year%%%10000-z
    set /a ut=y*365+y/4-y/100+y/400+(153*(100%Month%%%100+12*z-3)+2)/5+Day-719469
    set /a ut=ut*86400+100%Hour%%%100*3600+100%Minute%%%100*60+100%Second%%%100
    endlocal & set "%1=%ut%" & goto :EOF
    

    The result will be returned into the first parameter passed to GetUnixTime, i.e. %UNIX_TIME%.
    For example:

    1341791426 seconds have elapsed since 1970-01-01 00:00:00
    

    Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We all know the effects that lots of thrown exceptions can have over the
We all know that a hash table has O(1) time for both inserts and
I have a batch file that does several things and the last step is
Does anyone know of a batch processor or a VS 2010 plugin/script that would
The following command in a batch file does not work as expected/hoped: echo %~nxs1
Further to How to Pass Command Line Parameters in batch file how does one
Does anyone know of an easy way to create a script that can connect
We all know that openId has become such a popular method for user authentication,
We all know of sleep method available in java threads.. I understand that the
We all know that CSS sprite images are great to reduce the amount of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.