sp-dev-docs
sp-dev-docs copied to clipboard
List Formatting - Different dates are returned by the getDate operator depending on the time zone of the computer
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
Declarative list formatting
Developer environment
Windows
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [X] 💥 Microsoft Edge
- [X] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
No response
Describe the bug / error
I have observed that changing the time zone of the computer changes the value retrieved by the getDate operator and also retrieves a different value than the date in the date column.
Related Document: Formatting syntax reference
Steps to reproduce
Setting up a list for verification
- Create a date column with the internal name
Date
in the list - Set any date in the column created in step 1
- Create a column to display the values retrieved by the getDate operator
- Set the following JSON to the column formatting created in step 3
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=getDate([$Date])"
}
Change computer time zone
-
Change computer time zone from UTC+09:00 to UTC-09:00
-
When the list is reopened, the value obtained with the getDate operator is not the same as before the time zone change, and is different from the date in the date column
Expected behavior
The getDate
operator returns the date of the referencing date sequence without being affected by the computer's time zone.