Search notes:

System.TimeSpan (struct)

A System.TimeSpan represents the elapsed time between two time points which are represented by the System.DateTime struct.

Parse

In PowerShell, Parse() is the default method of the [timespan), so, in PowerShell, a timespan can be initialized like so:
[timespan] $two_minutes    =     '0:02'
[timespan] $four_hours     =     '4:00'
[timespan] $seven_seconds  =     '0:00:07'
[timespan] $three_days     =  '3:00:00:00'

[timespan] $negative_span  =    '-0:04'

ToString()

ToString() can be used to format a time span. Literal text must be enclosed within single quotes, or escaped with backslashes:
PS C:\> $ts = new-object TimeSpan 1, 23, 4, 56
PS C:\> $ts.ToString("d'd 'hh'h 'mm'm 'ss's'")
1d 23h 04m 56s
PS C:\> $ts.ToString("d\d\ hh\h\ mm\m\ ss\s")
1d 23h 04m 56s

See also

System.Diagnostics.Stopwatch is a class that allows to measure elapsed time. After measuring the elapsed period, it is returned by the Stopwatch's Elapsed property.
The PowerShell cmdLet new-timeSpan

Index