Powershell Get Date.ToString(';r';)返回错误的时间(GMT而不是本地时区)
PowerShell没有正确显示时间,并且忽略了我的本地时区-当前是00:20(在+2 GMT),但在获取时间时显示本地时间(00:20),但错误地打印GMT 正在运行脚本的服务器上检查,并且时区和本地时间设置正确 我做错什么了吗?还是这是一个错误Powershell Get Date.ToString(';r';)返回错误的时间(GMT而不是本地时区),powershell,Powershell,PowerShell没有正确显示时间,并且忽略了我的本地时区-当前是00:20(在+2 GMT),但在获取时间时显示本地时间(00:20),但错误地打印GMT 正在运行脚本的服务器上检查,并且时区和本地时间设置正确 我做错什么了吗?还是这是一个错误 $scriptStartDate = Get-Date Write-Host "time is $($scriptStartDate.ToString('r'))" # above line prints 'Sun, 14 Apr 2013 00:2
$scriptStartDate = Get-Date
Write-Host "time is $($scriptStartDate.ToString('r'))"
# above line prints 'Sun, 14 Apr 2013 00:20:00 GMT'
# this is wrong as wrong timezone, it should be 'Sun, 14 Apr 2013 00:20:00 E.Europe'
由您确定时间是否为UTC。您可以这样做:
[DateTime]::UtcNow.ToString('r')
此格式上的说明如下:
格式化不会修改日期时间的值;所以你
格式化之前,必须将该值调整为GMT