PowerTip: Use PowerShell to Display Date, Time, and Hour


Summary: Use Windows PowerShell to display date, time, and hour in 24-hour format.

Hey, Scripting Guy! Question How can I use Windows PowerShell to get the hour of the day in 24-hour format?

Hey, Scripting Guy! Answer Use the Get-Date cmdlet and specify the “%H” pattern to the UFormat parameter (H is case sensitive):

get-date -UFormat "%H"

Comments (6)

  1. mredwilson says:

    @Scripto I am glad you like it. Yes, this technique is something that I use to check things like AM and PM.

  2. Anonymous says:

    Thanks!!  Definitely will come in handy

  3. Scripto says:

    Heaps useful.

    Windows PowerShell

    Copyright (C) 2009 Microsoft Corporation. All rights reserved.

    PS H:> get-date -UFormat "%H"

    10

    PS H:>

  4. chiefkeef says:

    this info is not what im looking for….. not helpful whatsoever… bang bang

  5. mgchan67 says:

    Great! Just what I was looking for — a sortable date/timestamp

    PS C:> get-date -UFormat "%Y%m%d.%H%m%S"
    20151201.181253

Skip to main content