When trying to read a CSV yesterday, I noticed that PowerShell seems to always assume US date format when using [datetime]"date"
.
My regional settings are all correct, and [DateTime]::Parse("date")
uses the UK date format (dd/mm/yyyy).
Is this a bug, or a deliberate decision? If a deliberate decision, is this documented anywhere?
PS D:> [DateTime]"12/10/2012"
10 December 2012 00:00:00
PS D:> [DateTime]::Parse("12/10/2012")
12 October 2012 00:00:00
(Note: on a US machine, I expect these objects will be the same, but not so here on my machines in the UK).
Note: I don't want to change the format (it's a file from an external source), I don't want to format dates in output, I know I can use [DateTime]::Parse()
. The question is the bit that ends with a ?
:-)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…