![](/img/trans.png)
[英]Getting Date into UK time format correctly before writing to CSV - powershell
[英]Is there a simpler way to work with UK date format in Powershell?
按照我的喜好,要使用英國日期格式,以下代碼段將為我提供英國日期格式(Powershell不考慮計算機語言環境)。
$UKdate = [datetime]::Parse($req.ServicePoint.Certificate.GetExpirationDateString(),([Globalization.CultureInfo]::CreateSpecificCulture('en-GB')))
這似乎很笨拙,尤其是當語言通常如此簡潔時。 有我不知道的更好的方法嗎?
PowerShell確實考慮了語言環境,但沒有強制轉換為[DateTime]
。
也就是說,如果您要在英國文化中運行它,它將把它解析為英國日期:
Get-Date $req.ServicePoint.Certificate.GetExpirationDateString()
因此,這將始終選擇en-US
:
[DateTime]$req.ServicePoint.Certificate.GetExpirationDateString()
克里斯
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.