PowerTip: Use PowerShell to Display Time in 24-Hour Format


Summary: Use Windows PowerShell to display the current time in 24-hour format.

Hey, Scripting Guy! Question How can I use Windows PowerShell to display the current time in 24-hour format?

Hey, Scripting Guy! Answer Use the Get-Date cmdlet and the –UFormat parameter with %R:

Get-Date -UFormat %R

Comments (2)

  1. orthis says:

    Get-Date -Format HH:mm

  2. hong dari says:

    $24hourformat = $(get-date).ToString("yyyy/MM/dd HH:mm:ss.fff"); 
    $12hourformat = $(get-date).ToString("yyyy/MM/dd hh:mm:ss.fff");

Skip to main content