Setting the time of a System.DateTime object in PowerShell

I wish to set the System.DateTime object below with the time from $time:

$CurrentTime = (date)
$Time = "9:00"

How do I get the date from $CurrentTime, but with hours, minutes, seconds from $time?


Try this:


This should work:

$CurrentTime = [System.DateTime]::Parse((date).ToString("yyyy.MM.dd"))
$Time = [System.Timespan]::Parse("9:00")
$Result = $CurrentTime.Add($Time)

$CurrentTime = Get-Date -Hour "09" -Minute "00" -Second "00"

Get-Date -Year $CurrentTime.Year `
         -Month $CurrentTime.Month `
         -Day $CurrentTime.Day `
         -Hour $time.split(':')[0] `
         -Minute $time.split(':')[-1]
         -Second $time.split(':')[-1]

Need Your Help

How to find the imrect rectangle position changed or not?

matlab matlab-guide roi

I am working on imrect function in matlab to display canny and sobel edge of ROI of imrect rectangle .

Two way authorization with PFX file

ssl certificate mutual-authentication

I have a problem with two-way authentication. I Use tomcat6 as a server and as a client I try IE, Firefox and my own java application.