Description
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
- 💥 Microsoft Edge
- 💥 Google Chrome
- 💥 FireFox
- 💥 Safari
- mobile (iOS/iPadOS)
- mobile (Android)
- not applicable
- other (enter in the "Additional environment details" area below)
Additional environment details
Windows version with default locale to EN-IE, browser the same.
Describe the bug / error
When using the setValue functionality in list formatting and the @now token to set date and time, seems it always converts to american format, even when the browser locale/site settings are in other locale (EN-IE in my case).
For example, if @now was 12th of January 2024, it would be setting the value to 1st of December 2024.
And today as it is 23rd of January, as it seems that the function would use 23 as the month, I get an error:
When using a string on UTC format like in this sample I submitted, everything works fine:
https://github.com/pnp/List-Formatting/tree/master/column-samples/date-button-setValue-today
Steps to reproduce
- Create a Date Field named 'DateTripCompleted' in a List
- Apply below formatting JSON to the field
- Add a list item without a a value in this field
- Click the button displayed in the Field from the List View
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "children": [ { "elmType": "span", "txtContent": "[$DateTripCompleted.displayValue]", "attributes": { "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover" }, "style": { "display": "=if(Number([$DateTripCompleted]) ==0,'none','flex')" } }, { "elmType": "button", "customRowAction": { "action": "setValue", "actionInput": { "DateTripCompleted": "@now" } }, "attributes": { "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover" }, "style": { "border": "none", "background-color": "transparent", "cursor": "pointer", "display": "=if(Number([$DateTripCompleted]) ==0,'flex','none')", "align-items": "center" }, "children": [ { "elmType": "span", "attributes": { "iconName": "EventAccepted" }, "style": { "padding-right": "6px" } }, { "elmType": "span", "txtContent": "Mark Trip as Complete" } ] } ] }
Expected behavior
Value of date field to be set correctly.