You can use the Get-Date cmdlet in PowerShell to get the current date and time.
By default, the time component will be displayed in a 12-hour format with AM or PM appended at the end.
Here is what the various commands do:
- yyyy: 4-digit year number
- MM: 2-digit month number
- dd: 2-digit day number
- HH: 2-digit hours in 24-hour format
- mm: 2-digit minutes
- ss: 2-digit seconds
- fff: 3-digit milliseconds
By using HH for the hours, we specify that we would like the time to be shown in a 24-hour format.
If we instead used hh, then the time would be shown in a 12-hour format.

- Monday, April 22, 2024 2:34:07 PM
By default, the time is shown in a 12-hour format with PM appended at the end.

Notice that the time is now shown using a 24-hour format.

Notice that this returns just the time component from the Get-Date cmdlet formatted using a 24-hour format.
Note: You can find the complete documentation for the Get-Date cmdlet in PowerShell here.
How to Use Get-Date and Display Timezone in PowerShell
How to Compare Dates in PowerShell
How to Format a DateTime in PowerShell
How to Calculate Date Difference in PowerShell




