次の方法で共有


PowerShell One-Liner: List Time Formats

Part of the Power in PowerShell is access to .NET objects. Let's take the simple (ha!) Get-Date cmdlet.  It returns a DateTime object, which has many formatting options accessible in the GetDateTimeFormats class member.  Here's how we dump all 133 forms of the date, along with the index of the format.

PSH> (Get-Date).GetDateTimeFormats() | & { begin { $i = 0; } process { "{0}`t$_" -f $i++ } }

PSH> ((Get-Date).GetDateTimeFormats())[94]

2009-08-25 19:10:23

Comments

  • Anonymous
    August 30, 2009
    The comment has been removed