[英]SharePoint date result wrong using CAML and JavaScript
I have made a search using CAML + JavaScript from a SharePoint list.我使用 CAML + JavaScript 从 SharePoint 列表中进行了搜索。 In that list, there is date column with value is 2020-01-01 00:00
, for example.例如,在该列表中,有一个值为2020-01-01 00:00
的日期列。 When I run the code, the CAML give me the date 2019-12-31 23:00
.当我运行代码时,CAML 给我日期2019-12-31 23:00
。
Can someone help me?有人能帮我吗? Tks Tks
As Walker said,the time stored in SharePoint is in UTC time zone.正如沃克所说,存储在 SharePoint 中的时间是 UTC 时区。
You could convert it to local time this way.您可以通过这种方式将其转换为当地时间。 Append 'UTC' to the string before converting it to a date in javascript: Append 'UTC' 转换为字符串,然后将其转换为 javascript 中的日期:
Demo: new Date('5/8/2020 4:00:00 PM UTC').toLocaleString()
演示: new Date('5/8/2020 4:00:00 PM UTC').toLocaleString()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.