If you’d like to format information to given culture standards, this is really simple by using ToString() and the appropriate target information.

This example takes the current Date and Time, and outputs it in French format:

$date = Get-Date
$frenchCulture = New-Object -TypeName CultureInfo("fr")
$dateString = $date.ToString($frenchCulture)
$dateString

When you pick the Thai culture, you’ll notice a completely different year as Thailand is using a different calendar model:

$date = Get-Date
$thaiCulture = New-Object -TypeName CultureInfo("th")
$dateString = $date.ToString($thaiCulture)
$dateString

When you pick a different culture, Windows will also translate and display month and day names accordingly:

$date = Get-Date
$chineseCulture = New-Object -TypeName CultureInfo("zh")
$dateString = $date.ToString('dddd dd.MMMM yyyy',$chineseCulture)
$dateString

The result would look similar to this:

 
星期三 01.十一月 2017
 

Twitter This Tip! ReTweet this Tip!

Anonymous