Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell - Convert Ticks to Time

Tags:

powershell

Converting dates/times into ticks using the PowerShell Get-Date applet is simple. However, how do you do the opposite operation; converting the ticks back into a date and time?

like image 738
mkClark Avatar asked Jul 16 '09 21:07

mkClark


People also ask

Is a Tick a millisecond?

A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond (see TicksPerMillisecond) and 10 million ticks in a second.

What is DateTime Ticks?

What is Ticks. Ticks represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001, which represents DateTime. MinValue. A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.

What is a Tick time unit?

The smallest unit of time is the tick, which is equal to 100 nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.

How do I get the current date in powershell?

The Get-Date cmdlet gets a DateTime object that represents the current date or a date that you specify. Get-Date can format the date and time in several . NET and UNIX formats. You can use Get-Date to generate a date or time character string, and then send the string to other cmdlets or programs.


1 Answers

[DateTime]10000000000
Monday, January 01, 0001 12:16:40 AM

Just cast the number into a DateTime. The DateTime single-parameter constructor takes a long as number of ticks.

like image 85
Lee Avatar answered Sep 23 '22 03:09

Lee