Reputation: 75
I have the .csv file using 'MM DD YYYY HH:MM:SS' time format
Can I use the powershell convert to 'MMM DD, YYYY HH:MM:SS TT' ?
data.csv
09 17 2014 00:05:00,69.07217
09 17 2014 01:05:00,637.1816
09 17 2014 02:05:00,0.0
09 17 2014 03:05:00,481.296
I would like to ....
Sep 17, 2014 00:05:00 AM,69.07217
Sep 17, 2014 01:05:00 AM,637.1816
Sep 17, 2014 02:05:00 AM,0.0
Sep 17, 2014 03:05:00 AM,481.296
Upvotes: 0
Views: 725
Reputation: 201602
Something like this should work:
$dateTime = '09 17 2014 00:05:00'
"{0:MMM dd, yyyy HH:mm:ss tt}" -f [DateTime]::ParseExact($dateTime, 'MM dd yyyy HH:mm:ss', $null)
Outputs:
Sep 17, 2014 00:05:00 AM
Although if you want AM/PM shouldn't you use the 12-hour clock e.g. hh
?
Upvotes: 1