bat檔案顯示時間差

2021-08-31 02:33:45 字數 1187 閱讀 4781

指令碼一:顯示當前時間,暫停,然後按下任意鍵繼續,顯示當前時間,然後顯示兩個時間差。

@echo off

echo ruby start time is %time%

set time1h=%time:~0,2%

set time1m=%time:~3,2%

set time1s=%time:~6,2%

pause

echo ruby end time is %time%

set time2h=%time:~0,2%

set time2m=%time:~3,2%

set time2s=%time:~6,2%

set /a time3=(%time2h%-%time1h%)*3600 + (%time2m%-%time1m%)*60 + (%time2s%-%time1s%)

echo there was an interval of %time3% seconds for this operation.

指令碼二:顯示當前時間,迴圈執行某個命令100次,顯示執行完成後的當前時間,然後顯示兩個時間差。

@echo off

cd testdir

echo setup server

ruby start_server.rb rits

echo execute tools...

echo ruby start time is %time%

set time1h=%time:~0,2%

set time1m=%time:~3,2%

set time1s=%time:~6,2%

for /l %%i in (1,1,100) do ruby time_test.rb contents_refer

echo ruby end time is %time%

set time2h=%time:~0,2%

set time2m=%time:~3,2%

set time2s=%time:~6,2%

set /a time3=(%time2h%-%time1h%)*3600 + (%time2m%-%time1m%)*60 + (%time2s%-%time1s%)

echo there was an interval of %time3% seconds for this operation.

cd ..

計算時間差

計算時間差的問題,之前用的datediff datediff 返回跨兩個指定日期的日期和時間邊界數。語法datediff datepart startdate enddate 引數datepart 是規定了應在日期的哪一部分計算差額的引數。下表列出了 microsoft sql server 識別的...

計算時間差

php 初始化變數 stardate substr gstardate,0,10 enddate substr genddate,0,10 共有多少天 start mktime 0,0,0,substr stardate,5,2 substr stardate,8,2 substr stardate...

時間差計算

1 計算相差多少天,多少小時,多少分,多少秒 long nd 1000 24 60 60 一天的毫秒數 long nh 1000 60 60 一小時的毫秒數 long nm 1000 60 一分鐘的毫秒數 long ns 1000 一秒的毫秒數 date nowdate new date times...