Wednesday, 8 April 2015

PowerShell - Convert Ticks to DateTime and Vise Versa

You can convert Date to Ticks and Ticks to Date Time using the PowerShell Get-Date cmdlet.

Convert Ticks to DateTime

Use the below powershell command to convert ticks to date.
Get-Date 635641048517131910

Wednesday, April 08, 2015 3:47:31 PM
You can also convert ticks to datetime by simple DateTime type casting.
[DateTime]635641048517131910

Wednesday, April 08, 2015 3:47:31 PM

Convert DateTime to Ticks

Use the below powershell command to convert date to ticks.
(Get-Date).ticks

635641051132584348
(Get-Date "04/20/2014").ticks

635335488000000000

Advertisements
Advertisements

No comments:

Post a Comment