Secret Timespan Shortcuts

Usually, to create time spans, you will use New-Timespan. However, you can also use a more developer-centric approach by converting a number to a time span type:

[TimeSpan]100

This will get you a time span of 100 ticks, which is the smallest unit available to measure time. As PowerShell does support some hidden shortcuts for other units, this will create a time span of exactly five days:

[TimeSpan]5d

Twitter This Tip! ReTweet this Tip!


Posted Jul 13 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.