43

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.

0

4 Answers 4

40
prompt $t$g

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

3
  • 7
    prompt $T$H$H$H$G gives me exactly what I want May 14, 2011 at 20:58
  • 11
    prompt $T$H$H$H$S$P$G includes time & path Jun 13, 2016 at 19:37
  • 1
    This is great combined with automatically running this when you open cmd: superuser.com/a/54923 Nov 9, 2016 at 19:01
22

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.
1
2

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

1

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

"$P - $T$H$H$H$G" is the format string for the prompt, and the $ signs indicate characters with special meaning.

  • $P - current path
  • $T - current time - e.g. HH:MM:SS.SS (may vary with regional settings)
  • $H$H$H - backspace three characters to remove the .SS
  • $G - a "greater-than" sign at the end (>)

The end result looks something like: C:\Users - 12:34:56>

2
  • 5
    Could you explain?
    – Toto
    Nov 20, 2017 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, 2017 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .