Converting Ticks to Date and Time (Part 1)

by Apr 13, 2017

Occasionally, you may run into strange date and time representations: they might be represented as a 64-bit integer like this: 636264671350358729.

If you’d like to convert these “ticks” (the smallest time and date increment on Windows), simply convert the number to a DateTime type:

 
PS> [DateTime]636264671350358729

Thursday, March 30, 2017 10:38:55
 

Likewise, to turn a date into ticks, try this:

 
PS> $date = Get-Date -Date '2017-02-03 19:22:11'

PS> $date.Ticks
636217465310000000
 

You could use ticks to serialize date and time in a culture-neutral format, for example.

Twitter This Tip! ReTweet this Tip!