Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Add Days, Hours, and Minutes to Current Time

$
0
0

Summary: Use Windows PowerShell to easily add days, hours, and minutes to the current time.

Hey, Scripting Guy! Question How can I use Windows PowerShell to add one day, two hours, and thirty minutes to the current date and time?

Hey, Scripting Guy! Answer Create a TimeSpan object that represents one day, two hours, and thirty minutes,
          then add it to the current date and time that Get-Date retrieves:

$ts = New-TimeSpan -Days 1 -Hours 2 -Minutes 30

(get-date) + $ts


Viewing all articles
Browse latest Browse all 3333

Trending Articles