You are here: > PowerShell > PowerShell 1.0 > New-Timespan
ActiveXperts Network Monitor 2015 proactively manages network servers, devices, databases and more.

New-Timespan - PowerShell 1.0

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Back up your Hyper-V VMs Easy & Fast. 100% built for Hyper-V. Free for 2 VMs, forever.


The timespan can either be a specific number of days/hours/minutes
   or you can enter a Start/End and powershell will calculate the difference.

       The start of the timespan.

   -end DateTime
       The end of the timespan, may be piped. Default=Now

   -days int
       Days in the timespan.

   -hours int
       Hours in the timespan.

   -minutes int
       Minutes in the timespan.

   -seconds int
       Seconds in the timespan.


       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Create a TimeSpan object of duration 1 hour plus 90 minutes and store it in a variable named $mytspan:

PS C:\>$mytspan = new-timespan -hour 1 -minute 90

Create a new TimeSpan object for Jan 1970 - Jan 1971:

PS C:\>$mytspan = new-timespan (get-date -year 1970 -month 01) (get-date -year 1971 -month 01)