在Powershell中使用英国日期格式是否有更简单的方法?

时间:2016-08-04 09:17:27

标签: powershell

要使用英国日期格式,根据我的偏好,以下代码段将为我提供英国日期格式(Powershell不考虑机器区域设置)。

$UKdate = [datetime]::Parse($req.ServicePoint.Certificate.GetExpirationDateString(),([Globalization.CultureInfo]::CreateSpecificCulture('en-GB')))

这似乎很笨拙,特别是当语言通常如此简洁时。有没有更好的方法,我不知道?

1 个答案:

答案 0 :(得分:2)

PowerShell会考虑区域设置,但转换为select s.id, s.date, s.result, t_avgl2.result ,sum(list1) over (partition by id, date) ,avg(list1) over (partition by id, date) ,count(list1) over (partition by id, date) --totals: ,sum(list1) over () as total_sum ,avg(list1) over () as total_avg ,count(list1) over () as total_cnt from t_suml1 s inner join t_avgl2 a on s.id=a.id and s.date=a.date inner join t_countl3 c on s.id=c.id and s.date=c.date 则不会。

也就是说,如果你用英国文化来运行它,它会把它解析为英国日期:

[DateTime]

此处始终选择Get-Date $req.ServicePoint.Certificate.GetExpirationDateString()

en-US

克里斯