Merge Date and Time to DateTime

27/11/2013 11:23

Following date and time formats are used in InfoPath forms (value from Date or Time picker)

 

$dateString = "2013-11-27"
$timeString = "15:20:00"
$timeSplit = $timeString.Split(':');

$timeSpan = new-object System.TimeSpan($timeSplit[0],$timeSplit[1], $timeSplit[2]);
$timeSpan

$dateTime = [System.Convert]::ToDateTime($dateString);
$dateTime

$dateTimeTogether = $dateTime + $timeSpan
$dateTimeTogether

$current = [System.DateTime]::Now
$current

$difference = $dateTimeTogether-$current
$difference