Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Date-time string converting to special format

$
0
0

Hi,

I have a task scheduler script. The 2 boxes I ask user for date and time. The date format user inputs is in 12-10-2012 format, and time is military so 10:54:30. The task scheduler wants format of 2012-12-10T10:54:30. I am using the following code:

$a = "{0:yyyy-MM-dd}" -f [datetime]$objTextBox2.Text
$startTime = $a + "T" + $objTextBox4.Text
Result: 2012-12-10T10:54:30

2012-12-10T10:54:30 is going to be my execute time for task, now what I want to do is take 2012-12-10T10:54:30 string convert in powershell to date time format and add 10 minutes, this will give me the expiration date-time variable which i can use in scheduled task. I was thinking using [datetime]::ParseExact() but dont know how to specify both date and time plus there is a T in the middle.

Could anyone help?

Thanks


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>