Convert US datetime string to UK

Can someone please help me with the following

I have a bunch of date strings in US format (month/day/year) like so

6/22/2017 12:00:00 AM

01/01/2019 10:00:00 PM

I want to convert these to a UK datetime

If I do the following

[datetime]([datetime]"6/22/2017 10:00:00 AM ").ToString(“MM/dd/yy hh:mm:ss”)

It works OK as follows

22 June 2017 10:00:00

However, if I change to PM as follows

[datetime]([datetime]"6/22/2017 10:00:00 PM ").ToString(“MM/dd/yy hh:mm:ss”)

I still get the same output as follows

22 June 2017 10:00:00

I want the above to show the hour 22:00:00

Can someone kindly help me with this, thanks very much in advance

Actually I just figured it out (sorry)

datetime]([datetime]"6/22/2017 10:00:00 PM ").ToString(“MM/dd/yy hh:mm:ss tt”)

1 Like

Another method:

Get-Date -Date "6/22/2017 10:00:00 PM " -Format "MM/dd/yy hh:mm:ss tt"
1 Like

Thanks very much Rob