Countdown Hours

by Sep 3, 2014

All PowerShell Versions

Whether it is a birthday or an important game, you may want PowerShell to tell you just how many hours it is till the event starts. Here is how:

$result = New-TimeSpan -End '2014-12-25 06:45:00'
$hours = [Int]$result.TotalHours
'Another {0:n0} hours to go...' -f $hours 

This example calculates the hours to go until Christmas 2014. Simply replace the date in this piece of code to find out just how many more hours you need to wait for your favorite event to start.

Twitter This Tip! ReTweet this Tip!