1
我想在午夜的日期/時間字段設置爲一個值:SharePoint列表日期/時間字段轉換爲通用時間
# Tuesday, May 19, 2015 12:00:00 AM
$Properties = @{CompletedDate = [DateTime]::Today}
...
$Payload = $Properties | ConvertTo-Json
$headers = @{
"X-HTTP-Method" = "MERGE";
"If-Match" = "*"
}
Invoke-WebRequest -Uri $url -Method Post -UseDefaultCredentials -Headers $headers -ContentType "application/json" -Body $Payload
它的出現,然而,該日期被調整爲通用時間:
<entry>
<content>
<m:properties>
...
<d:CompletedDate m:type="Edm.DateTime">2015-05-19T04:00:00</d:CompletedDate>
如果我想CompletedDate
實際2015-05-19T00:00:00,什麼是保證這一目標的最佳方式是什麼?
我想,一個選擇是:
$today = Get-Date -Date ('{0}/{1}/{2} 00:00:00Z' -f (Get-Date).year, (Get-Date).month, (Get-Date).day)
$Properties = @{CompletedDate = $today}
有沒有更有效的方法是什麼?
爲JS,使用toLocaleDateString()方法。 – nbi