Link to home
Start Free TrialLog in
Avatar of itnifl
itniflFlag for Norway

asked on

Get date in powershell in the format d.M.yyyy hh:mm AM/PM

I am trying to get the date in this format

(get-date).AddMinutes(10).ToString("d.M.yyyy hh:mm tt")

Where tt should be AM or PM. But I guess tt is wrong to use here.

All help appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your Code is correct:

PS G:\Documents\WindowsPowerShell\Scripts> (get-date).addminutes(10).tostring("d.M.yyyy hh:mm tt")
23.2.2014 01:03 PM
PS G:\Documents\WindowsPowerShell\Scripts>

Open in new window

Avatar of itnifl

ASKER

David Johnson, CD, MVP:
But not on my system, most likely because I am not using a system with US local settings. I tested Rainer Jeschor solution, and it seems to work by setting these settings manually in the script.

But thank you anyway =)