One easy option is to use FINDSTR /R
to do a regular expression check if the time has the right number of digits.
set tm=43:00:00
echo %tm%| findstr /R "^[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$"
if errorlevel 1 (
echo Invalid time!
) else (
echo OK
)
The problem with that approach is that FINDSTR only has limited regex support, so you can't really tell with the above if the time actually makes sense (e.g. if hour is 25...)
You could improve the script by doing a few separate checks. For example: if the hour's first digit is [2] then the second digit must be [0-3]. However, for all that effort, I'd rather just call out to a simple PowerShell script to do check if the time is correct and use the output from the PS script in your batch file.