42

I would like my command prompt (not powershell, just command prompt) to show the time, something like this:

14:02>

Is there a way to do this? Basically, I leave things running from the prompt, and it would be nice to see what time I executed various commands.

Linger
  • 3,274
  • 10
  • 35
  • 47
Daniel Williams
  • 1,484
  • 7
  • 19
  • 29

4 Answers4

40
prompt $t$g

And see http://ss64.com/nt/prompt.html for a complete list

studiohack
  • 13,468
  • 19
  • 88
  • 118
GroovyDotCom
  • 518
  • 6
  • 6
21

Attempt 1

Using prompt $t$g (as in the currently accepted answer) results in a prompt as in this example:

14:32:46,28>

Attempt 2

Using prompt $P - $T$H$H$H$G (as in the previously posted answer) results in a prompt like in this example:

C:\Users\Pierre.Vriens - 14:32:46>

Attempt 3

Using prompt $T$H$H$H$H$H$H$G (as mentioned also in a comment from OPer below the currently accepted answer) results in a prompt like in this example:

14:33>

So it looks like this attempt (= nr 3) is the correct answer ... (Credits: Daniel Williams), because:

  • $T results in 14:32:46,28.
  • $H$H$H$H$H$H performs, 6 times, a backspace (i.e. removes the :46,28 part of that).
  • $G adds > to it again.
Pierre.Vriens
  • 1,415
  • 38
  • 16
  • 20
  • Adding link to Microsoft documentation: [Windows Commands - prompt](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/prompt) – datalifenyc Apr 01 '21 at 10:28
1

prompt $P - $T$H$H$H$G to have it more nicely maybe

chloesoe
  • 716
  • 3
  • 10
Petro
  • 19
  • 2
  • 5
    Could you explain? – Toto Nov 20 '17 at 13:25
  • 3
    go to this PC properties, Advanced settings, Environment, System variables, and add a variable PROMPT with the value I did mentioned so that you will have all future cmd prompts you will open with that prompt ;) Have fun. – Petro Nov 22 '17 at 08:30
1

use time /t to display the time use tzutil /g to get the timezone info