CmdID / PowerShell / Cmdlets / New
New-TimeSpan
Creates a TimeSpan object. PowerShell reference
From the PowerShell reference 6 parameters
What it does
Creates a TimeSpan object. The New-TimeSpan cmdlet creates a TimeSpan object that represents a time interval. You can use a TimeSpan object to add or subtract time from DateTime objects. Without parameters, a New-TimeSpan command returns a TimeSpan object that represents a time interval of zero.
New-TimeSpan [[-Start] <DateTime>] [[-End] <DateTime>] [<CommonParameters>]New-TimeSpan [-Days <Int32>] [-Hours <Int32>] [-Minutes <Int32>] [-Seconds <Int32>] [<CommonParameters>]
Create a TimeSpan object for a specified duration
$TimeSpan = New-TimeSpan -Hours 1 -Minutes 25
$TimeSpanIdentifyCreate a TimeSpan object for a time interval
New-TimeSpan -End (Get-Date -Year 2010 -Month 1 -Day 1)IdentifyGet the date 90 days from the current date
$90days = New-TimeSpan -Days 90
(Get-Date) + $90daysIdentifyDiscover the TimeSpan since a file was updated
Get-ChildItem $PSHOME\en-US\about_remote.help.txt | New-TimeSpanIdentifyIts page in the reference: New-TimeSpan.
Parameters
-DaysSpecifies the days in the time span. The default value is 0.-EndSpecifies the end of a time span. The default value is the current date and time.-HoursSpecifies the hours in the time span. The default value is zero.-MinutesSpecifies the minutes in the time span. The default value is 0.-SecondsSpecifies the length of the time span in seconds. The default value is 0.-StartSpecifies the start of a time span. Enter a string that represents the date and time, such as "3/15/09" or a DateTime object, such as one from a Get-Date command. The default value is the current date and time.
You can use Start or its alias, LastWriteTime. The LastWriteTime alias lets you pipe objects that have a LastWriteTime property, such as files in the file system ([IO.FileInfo]), to the Start parameter of New-TimeSpan.