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 7750937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:25:13+00:00 2026-06-01T11:25:13+00:00

How can I get the difference between two times in a Batch file? Because

  • 0

How can I get the difference between two times in a Batch file? Because I want to print it in an HTML file.

I thought this would be possible, but it isn’t.

Set "tijd=%time%"
echo %tijd%
echo %time%-%tijd%

Results:

11:07:48,85
11:16:58,99-11:07:48,85

But what I want is:

00:09:10,14

Or 9 minutes and 10 seconds or 550 seconds

  • 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-01T11:25:15+00:00Added an answer on June 1, 2026 at 11:25 am

    As answered here:
    How can I use a Windows batch file to measure the performance of console application?

    Below batch "program" should do what you want. Please note that it outputs the data in centiseconds instead of milliseconds. The precision of the used commands is only centiseconds.

    Here is an example output:

    STARTTIME: 13:42:52,25
    ENDTIME: 13:42:56,51
    STARTTIME: 4937225 centiseconds
    ENDTIME: 4937651 centiseconds
    DURATION: 426 in centiseconds
    00:00:04,26
    

    Here is the batch script:

    @echo off
    setlocal
    
    rem The format of %TIME% is HH:MM:SS,CS for example 23:59:59,99
    set STARTTIME=%TIME%
    
    rem here begins the command you want to measure
    dir /s > nul
    rem here ends the command you want to measure
    
    set ENDTIME=%TIME%
    
    rem output as time
    echo STARTTIME: %STARTTIME%
    echo ENDTIME: %ENDTIME%
    
    rem convert STARTTIME and ENDTIME to centiseconds
    set /A STARTTIME=(1%STARTTIME:~0,2%-100)*360000 + (1%STARTTIME:~3,2%-100)*6000 + (1%STARTTIME:~6,2%-100)*100 + (1%STARTTIME:~9,2%-100)
    set /A ENDTIME=(1%ENDTIME:~0,2%-100)*360000 + (1%ENDTIME:~3,2%-100)*6000 + (1%ENDTIME:~6,2%-100)*100 + (1%ENDTIME:~9,2%-100)
    
    rem calculating the duration is easy
    set /A DURATION=%ENDTIME%-%STARTTIME%
    
    rem we might have measured the time in-between days
    if %ENDTIME% LSS %STARTTIME% set set /A DURATION=%STARTTIME%-%ENDTIME%
    
    rem now break the centiseconds down to hours, minutes, seconds and the remaining centiseconds
    set /A DURATIONH=%DURATION% / 360000
    set /A DURATIONM=(%DURATION% - %DURATIONH%*360000) / 6000
    set /A DURATIONS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000) / 100
    set /A DURATIONHS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000 - %DURATIONS%*100)
    
    rem some formatting
    if %DURATIONH% LSS 10 set DURATIONH=0%DURATIONH%
    if %DURATIONM% LSS 10 set DURATIONM=0%DURATIONM%
    if %DURATIONS% LSS 10 set DURATIONS=0%DURATIONS%
    if %DURATIONHS% LSS 10 set DURATIONHS=0%DURATIONHS%
    
    rem outputing
    echo STARTTIME: %STARTTIME% centiseconds
    echo ENDTIME: %ENDTIME% centiseconds
    echo DURATION: %DURATION% in centiseconds
    echo %DURATIONH%:%DURATIONM%:%DURATIONS%,%DURATIONHS%
    
    endlocal
    goto :EOF
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHP + mongoDB. How can I get a time difference between two
Can someone explain why I get different results from these two statements? I thought
I was doing a simple calculation to get the difference between two dates. If
Where can I get a summary of differences between ActionScript 3.0 strict and standard
How can I get all differences, not just one? I want to use the
I want to calculate the average CPU usage % between two points of time.
I have a time difference between two datetimes. The interval in seconds is 3660
Where can I get a list of browser differences in the implementation of DOM?
I am working on MotionEvent by which i can get different - different gesture
Can you get the distinct combination of 2 different fields in a database table?

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.