Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am running a bunch of commands in a command prompt on a Windows server over a period of time and I would like to see when I last ran a command. I used the prompt command to customize the prompt.

prompt $t $p$g

to get a prompt that looks like

13:02:50.64 L:\>

I would like to use 12 hour time in the prompt and drop off the tenths/hundredths of a second, but it doesnt appear there is an option to do this. I would like for it to look like

1:02:50PM L:\>

Perhaps someone knows a way?


Using

prompt $T$H$H$H $p$g

gets me a prompt that looks like

15:35:11 L:\>

Which is closer, but it doesnt look like it will do 12 hour format.

share|improve this question
    
Not really an answer for cmd.exe but in PowerShell you can do function prompt {"$(get-date -format h:mm:sstt) $(get-location)> "}. A pity cmd.exe is not as powerful :( (maybe you can run the commands in a powershell :) –  Rik Oct 28 '13 at 21:30
    
I can, however cmd is old habit that is hard to break –  Keltari Oct 28 '13 at 22:01

2 Answers 2

For the PROMPT command, from this page, it says to use $T for 12-hour time. This DOES still have the tenths/hundredths of a second, but I don't think this can be removed.

share|improve this answer
3  
Maybe you can use $H to remove the fraction? –  Oliver Salzburg Oct 28 '13 at 18:28
2  
prompt $T $p$g does not give a 12 hour format in cmd.exe. The linked site is only for the "Take Command" (TCC) environment (a non-free replacement for cmd.exe). Not for the normal cmd.exe command prompt. –  Rik Oct 28 '13 at 18:57
1  
The $H worked (prompt $T$H$H$H $p$g) Which is an improvement. but there as @Rik said, the other command is for another shell –  Keltari Oct 28 '13 at 19:36

Edit: The information below is wrong. The system locale settings will affect the time format returned by TIME /T at the command prompt, but apparently the $T in the prompt string is always in 24-hour format.

The $T variable in the prompt string is linked to the "Long Time" format setting in Windows. If your Windows settings specify a 24-hour time clock, that will be reflected by $T. To get 12-hour time, you need to change the Windows locale settings (which may not be desirable, because it will be system wide).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.