Skip to main content

How to Get the System Date and Time in Windows PowerShell

Problem

You want to get the system date.

Solution

To get the system date, run the command GetDate.

Discussion

The GetDate command generates rich objectbased output, so you can use its result for many daterelated tasks. For example, to determine the current day of the week:

PS >$date = GetDate PS >$date.DayOfWeek Sunday

For more information about the GetDate cmdlet, type GetHelp GetDate.

Help Category