Click here for important information about

Batch: Standard time?

August 12, 2010 at 16:47:44
Specs: Windows Vista
Is it possible for batch to print out the standard time (AM, PM; opposed to military)? Is there such a command or variable? If not, do you know of any other programming language that could print the standard time?

See More: Batch: Standard time?

August 12, 2010 at 19:42:14
@echo off
for /f "tokens=1,2,3 delims=:" %%a in ('echo %time%') do (
set hr=%%a
set min=%%b
set secs=%%c
set /a pm=0
if %hr% GTR 12 (
set /a hr=%hr%-12
set /a pm=1
if %pm%==0 echo Time is %hr%.%min%AM
if %pm%==1 echo Time is %hr%.%min%PM

Report •

August 12, 2010 at 20:44:53
This is loads of help. I'm not entirely sure what the tokens part does, but I can roughly see how the whole program works. It works great. Thanks for the help, I appreciate it!

Report •
Related Solutions

Ask Question