One of my team members recently searched for a solution to convert a string to a date in PowerShell. I suggested different methods. In this tutorial, I will show you how to convert a string to a date in PowerShell with examples.
To convert a string to a date in PowerShell, you can use the [datetime] type accelerator. For example, if you have a date string like "08/19/2024", you can convert it by using [datetime]::ParseExact("08/19/2024", "MM/dd/yyyy", $null). This method ensures the string is interpreted correctly according to the specified format.
Convert String to Date in PowerShell
Now, let me show you how to convert a string to a date in PowerShell using different methods.
Method 1: Using Get-Date
The Get-Date cmdlet is useful in PowerShell and can be used to convert a string to a DateTime object.
Here is an example.
$dateString = "08/09/2025"
$date = Get-Date $dateString
Write-Output $dateIn this example, the string “08/09/2025” is converted to a DateTime object using Get-Date.
I executed the above PowerShell script, and you can see the output in the screenshot below:

Method 2: Using [datetime]::Parse()
The [datetime]::Parse() method is another way to convert a string to an DateTime object in PowerShell. This method is particularly useful when dealing with different date formats.
Here is an example.
$dateString = "19-Aug-2025"
$date = [datetime]::Parse($dateString)
Write-Output $dateHere, the string “09-Jun-2025” is parsed into a DateTime object.
Here is the output you can see in the screenshot below:

Check out Convert String to Double in PowerShell
Method 3: Using [datetime]::ParseExact()
Now, let me show you another method to convert string to date in PowerShell using [datetime]::ParseExact(). This method requires you to specify the exact format of the date string.
Here is an example.
$dateString = "2025-06-09"
$format = "yyyy-MM-dd"
$date = [datetime]::ParseExact($dateString, $format, $null)
Write-Output $dateIn this example, the string “2025-06-09” is parsed using the format “yyyy-MM-dd”.
Method 4: Using Get-Date with -Format Parameter
The -Format parameter of Get-Date can be used to specify the desired format of the output.
Here is an example of how we can use the Get-Date with -Format parameter to convert string to date in PowerShell.
$dateString = "06/09/2025"
$date = Get-Date $dateString -Format "yyyy-MM-dd"
Write-Output $dateThis converts the string “06/09/2025” to a DateTime object and formats it as “yyyy-MM-dd”.
Here is the output in the screenshot below, you can see:

Check out Convert String to Hashtable in PowerShell
Handle Different Date Formats
In real-world scenarios, you might encounter various date formats. Here are some examples of how to handle them:
Example 1: Convert US Date Format (MM/dd/yyyy)
Here is an example of how to convert a date to a US date format in PowerShell.
$dateString = "06/09/2025"
$format = "MM/dd/yyyy"
$date = [datetime]::ParseExact($dateString, $format, $null)
Write-Output $dateExample 2: Convert European Date Format (dd/MM/yyyy)
Here is an example of how to convert string to European Date Format in PowerShell.
$dateString = "09/06/2025"
$format = "dd/MM/yyyy"
$date = [datetime]::ParseExact($dateString, $format, $null)
Write-Output $dateRead Convert String to JSON in PowerShell
Convert string to date with timezone using PowerShell
Now, let me show you how to convert string to date with timezone using PowerShell. There are different methods to do this.
Using ParseExact Method
You can use the ParseExact method to convert string to date with timezone using PowerShell. Here is an example:
$timeString = '2025-08-19 03:00:00 -0400'
$format = 'yyyy-MM-dd HH:mm:ss zzz'
$culture = [System.Globalization.CultureInfo]::InvariantCulture
$datetime = [datetime]::ParseExact($timeString, $format, $culture)Handle Time Zones
To handle time zones explicitly, you can use the TimeZoneInfo class:
$timeString = '2025-08-19 03:00:00'
$timeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById('Eastern Standard Time')
$datetime = [datetime]::Parse($timeString)
$datetimeWithTimeZone = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId($datetime, $timeZone.Id)Read How to Convert Base64 String to Text in PowerShell?
Convert String to Date without Time using PowerShell
Now, let me show you how to convert string to date without time using PowerShell.
To convert a string to a date without the time component in PowerShell, you can use the [datetime]::ParseExact method. This method allows you to specify the exact format of the date string and parse it accordingly. Once parsed, you can access the .Date property to get just the date part.
Example
Let’s say you have a date string in the format yyyy-MM-dd , and you want to convert it to a date object without the time component.
Here is the complete PowerShell script.
# Define the date string
$dateString = '2025-08-19'
# Define the format of the date string
$format = 'yyyy-MM-dd'
# Parse the date string to a DateTime object
try {
$dateTime = [datetime]::ParseExact($dateString, $format, [System.Globalization.CultureInfo]::InvariantCulture)
} catch {
Write-Error "Failed to parse date string: $_"
return
}
# Get only the date part
$dateOnly = $dateTime.Date
# Output the result
Write-Output $dateOnlyExplanation
- Define the Date String: The variable
$dateStringholds the date in string format. - Define the Format: The
$formatvariable specifies the format of the date string. - ParseExact Method: The
[datetime]::ParseExactmethod is used to convert the string to aDateTimeobject. It takes the date string, the format, and a culture info object. - Extract the Date: The
.Dateproperty of theDateTimeobject is accessed to get only the date part, which strips off the time component.
This method ensures that the conversion is accurate and the resulting DateTime object contains only the date without any time information.
You can see the output in the screenshot below after I executed the above PowerShell script.

Read Convert String to Int in PowerShell
PowerShell: Convert String to Date yyyymmddhhmmss
To convert a string in the format yyyyMMddHHmmss to a DateTime object in PowerShell, you can use the [datetime]::ParseExact method. This method allows you to specify the exact format of the date and time string and parse it accordingly.
Example
Let’s say you have a date and time string in the format yyyyMMddHHmmss, and you want to convert it to a DateTime object. Here is the complete PowerShell script.
# Define the date and time string
$dateString = '20240819083045'
# Define the format of the date and time string
$format = 'yyyyMMddHHmmss'
# Parse the date and time string to a DateTime object
$dateTime = [datetime]::ParseExact($dateString, $format, [System.Globalization.CultureInfo]::InvariantCulture)
# Output the result
$dateTimeExplanation
- Define the Date and Time String: The variable
$dateStringholds the date and time in string format. - Define the Format: The
$formatvariable specifies the format of the date and time string usingyyyyMMddHHmmss. - ParseExact Method: The
[datetime]::ParseExactmethod is used to convert the string to aDateTimeobject. It takes the date and time string, the format, and a culture info object. - Output the Result: The resulting
DateTimeobject is stored in the$dateTimevariable and then outputted.
This method ensures that the conversion is accurate and the resulting DateTime object correctly represents the date and time specified in the string.
You can also see the output in the screenshot below, after I executed the above PowerShell script.

Check out How to Convert String to Boolean in PowerShell?
Convert String to Datetime AM/PM using PowerShell
To convert a string that includes an AM/PM designation to a DateTime object in PowerShell, you can use the [datetime]::ParseExact method. This method allows you to specify the exact format of the date and time string and parse it accordingly.
Example
Suppose you have a date and time string in the format MM/dd/yyyy hh:mm tt (where tt denotes the AM/PM designator) and you want to convert it to a DateTime object.
# Define the date and time string
$dateString = '08/19/2024 03:45 PM'
# Define the format of the date and time string
$format = 'MM/dd/yyyy hh:mm tt'
# Parse the date and time string to a DateTime object
$dateTime = [datetime]::ParseExact($dateString, $format, [System.Globalization.CultureInfo]::InvariantCulture)
# Output the result
$dateTimeExplanation
- Define the Date and Time String: The variable
$dateStringholds the date and time in string format, including the AM/PM designator. - Define the Format: The
$formatvariable specifies the format of the date and time string usingMM/dd/yyyy hh:mm tt. Here:MMis the two-digit month.ddis the two-digit day.yyyyis the four-digit year.hhis the two-digit hour (12-hour clock).mmis the two-digit minute.ttis the AM/PM designator.
- ParseExact Method: The
[datetime]::ParseExactmethod is used to convert the string to aDateTimeobject. It takes the date and time string, the format, and a culture info object. - Output the Result: The resulting
DateTimeobject is stored in the$dateTimevariable and then outputted.
This method ensures that the conversion is accurate and the resulting DateTime object correctly represents the date and time specified in the string, including the AM/PM designator.
Read Convert Strings to Lowercase or Uppercase in PowerShell
PowerShell Convert String to Datetime UTC
To convert a string to a DateTime object in UTC in PowerShell, you can use the [datetime]::ParseExact method along with the ToUniversalTime method. This allows you to specify the format of the date string, parse it, and then convert it to UTC.
Let me show you an example.
Example
Let’s say you have a date and time string in the format yyyy-MM-dd HH:mm:ss and you want to convert it to a DateTime object in UTC.
# Define the date and time string
$dateString = '2024-08-19 15:30:00'
# Define the format of the date and time string
$format = 'yyyy-MM-dd HH:mm:ss'
# Parse the date and time string to a DateTime object
$dateTime = [datetime]::ParseExact($dateString, $format, [System.Globalization.CultureInfo]::InvariantCulture)
# Convert the DateTime object to UTC
$dateTimeUTC = $dateTime.ToUniversalTime()
# Output the result
$dateTimeUTCExplanation
- Define the Date and Time String: The variable
$dateStringholds the date and time in string format. - Define the Format: The
$formatvariable specifies the format of the date and time string usingyyyy-MM-dd HH:mm:ss. - ParseExact Method: The
[datetime]::ParseExactmethod is used to convert the string to aDateTimeobject. It takes the date and time string, the format, and a culture info object. - Convert to UTC: The
.ToUniversalTime()method is called on theDateTimeobject to convert it to UTC. - Output the Result: The resulting
DateTimeobject in UTC is stored in the$dateTimeUTCvariable and then outputted.
This method ensures that the conversion is accurate and the resulting DateTime object correctly represents the date and time in UTC.
Check out Convert Variables to Strings in PowerShell
Convert String to Datetime 24 hour format using PowerShell
To convert a string in a 24-hour time format to a DateTime object in PowerShell, you can use the [datetime]::ParseExact method. This method allows you to specify the exact format of the date and time string and parse it accordingly.
Let me show you an example.
Example
Let’s say you have a date and time string in the format yyyy-MM-dd HH:mm:ss and you want to convert it to a DateTime object.
# Define the date and time string
$dateString = '2024-08-19 14:30:00'
# Define the format of the date and time string
$format = 'yyyy-MM-dd HH:mm:ss'
# Parse the date and time string to a DateTime object
$dateTime = [datetime]::ParseExact($dateString, $format, [System.Globalization.CultureInfo]::InvariantCulture)
# Output the result
$dateTimeExplanation
- Define the Date and Time String: The variable
$dateStringholds the date and time in string format in 24-hour time. - Define the Format: The
$formatvariable specifies the format of the date and time string usingyyyy-MM-dd HH:mm:ss.yyyyis the four-digit year.MMis the two-digit month.ddis the two-digit day.HHis the two-digit hour in 24-hour format.mmis the two-digit minute.ssis the two-digit second.
- ParseExact Method: The
[datetime]::ParseExactmethod is used to convert the string to aDateTimeobject. It takes the date and time string, the format, and a culture info object. - Output the Result: The resulting
DateTimeobject is stored in the$dateTimevariable and then outputted.
This method ensures that the conversion is accurate and the resulting DateTime object correctly represents the date and time specified in the string in 24-hour format.
Convert String to Date and Add Days in PowerShell
To convert a string to a DateTime object and then add days to it in PowerShell; you can use the [datetime]::ParseExact method to parse the string and the AddDays method to add days to the resulting DateTime object.
Let me show you an example.
Example
Let’s say you have a date string in the format yyyy-MM-dd and you want to convert it to a DateTime object and then add 10 days to it.
# Define the date string
$dateString = '2024-08-19'
# Define the format of the date string
$format = 'yyyy-MM-dd'
# Parse the date string to a DateTime object
$dateTime = [datetime]::ParseExact($dateString, $format, [System.Globalization.CultureInfo]::InvariantCulture)
# Add 10 days to the DateTime object
$newDateTime = $dateTime.AddDays(10)
# Output the result
$newDateTimeExplanation
- Define the Date String: The variable
$dateStringholds the date in string format. - Define the Format: The
$formatvariable specifies the format of the date string usingyyyy-MM-dd. - ParseExact Method: The
[datetime]::ParseExactmethod is used to convert the string to aDateTimeobject. It takes the date string, the format, and a culture info object. - Add Days: The
.AddDays(10)method is called on theDateTimeobject to add 10 days to it. - Output the Result: The resulting
DateTimeobject, with 10 days added, is stored in the$newDateTimevariable and then outputted.
This method ensures that the conversion is accurate and the resulting DateTime object correctly represents the date with the specified number of days added.
Conclusion
In this tutorial, I have explained how to convert string to date in PowerShell using different methods. You can use various methods like:
- Use
Get-Datefor simple conversions. - Use
[datetime]::Parse()for more flexibility. - Use
[datetime]::ParseExact()for precise control over date formats. - Use
Get-Datewith the-Formatparameter for specific output formats.
I have also explained the below examples:
- Convert string to date with timezone using PowerShell
- Convert String to Date without Time using PowerShell
- PowerShell: Convert String to Date yyyymmddhhmmss
- Convert String to Datetime AM/PM using PowerShell
- PowerShell Convert String to Datetime UTC
- Convert String to Datetime 24-hour format using PowerShell
- Convert String to Date and Add Days in PowerShell
I hope this helps you. Do let me know in the comments below if you have any questions.
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.