-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date formatting for custom Date and Time column #115
Comments
Hi @RedGlow With the Finally, if you use only the |
@RedGlow any update on this? |
I have the same issue. I have a custom Date Time column that only stores the date value. The getdate handlebar expression in the search results webpart does not convert the UTC date time to the local time. After some investigation i realised this is because the value coming from the managed property StampDateOWSDATE is missing the Z at the end and this is causing the conversion from UTC to fail. I fixed this by adding the Z to my datetime string. However this is not a very elegant solution. Would appreciate if anyone else has found a better way to fix this issue. |
Added an extra parameter. You can now (next version) use the below format and it will append a Z to the date if it's missing.
|
Version used
3.6.3.0
Describe the bug
I have a problem regarding formatting dates which I don't know if it's related to the Search Results webpart or SharePoint in general. In summary, I have a custom Date and Time column in a list whose values I'd like to show in the Search Results webpart, but I can't get to format the result in the correct timezone using Handlebars templates.
Details
More in details, I have a list with a custom Date and Time column (namely
ArrivalDate
). If I directly access the content of the property through REST API, I get the ISO 8601 UTC content I expect:The column has two associated crawled properties:
Ows_ArrivalDate
Ows_q_DATE_ArrivalDate
From these crawled properties I have the automatically generated managed property
ArrivalDateOWSDATE
, and then, in order to make some extra tests, I mapped each crawled property to aRefinableString
(112 and 113) and aRefinableDate
(15 and 16). All five managed properties are giving me the date in the format “2/16/2020 11:00:00 PM”:This date is in the wrong format for the
getDate
Handlebars helper to format it as per documentation (which states it should be an ISO 8601 UTC format): it works anyway, but it obviously ignores the timezone data (I am in a timezone with +01:00, which would make the date 2/17/2020, and instead it is printed as 2/16/2020).From ticket #28 I got the idea to make a couple more tests. I got the
webTimeZoneData
, which has an ID of 3, and null foruserTimeZoneData
. Replaying the same search query the webpart performs and adding a"TimeZoneId": 3
parameter, though, does not change the output parameter of the search, so I suppose it's only pertinent to the interpretation of the filters.So, my conclusion right now is that the values returned by SharePoint in this configuration are always UTC, but in a format that is not recognized as such by the webpart. Maybe, in that case, the solution could be to just give an option to
getDate
that allows the date to be re-formatted? Using moment, I would do something like:The text was updated successfully, but these errors were encountered: