Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Vijay 13 posts 83 karma points
    Feb 16, 2024 @ 14:24

    Assistance Needed with Date Format Issue in Umbraco Backend

    Hello All,

    I am encountering an issue with date formatting in the Umbraco backend. When inputting dates using the date picker property, I'm noticing inconsistencies in how the dates are displayed, particularly across different cultures. In some cases, the date format appears as "11/21/2023 12:00:00 AM" (as shown in the first image), while in others, it's displayed as "0001-01-01T00:00:00" (as shown in the second image), which appears to be an unknown format.

    This inconsistency is causing confusion and hindering the usability of the system, as users expect the dates to be displayed consistently.

    Could you please provide guidance on how to address this issue? Specifically, I would like to either:

    Configure the date picker property to accept dates in a consistent format, preferably in the English calendar format ("MM/dd/yyyy HH:mm:ss tt").

    Alternatively, provide instructions on how to retrieve the date content directly in its raw format so that I can handle the formatting myself, or programmatically convert it to the English calendar format.enter image description here

    Any assistance or guidance you can provide to resolve this issue would be greatly appreciated. Please let me know if you require further clarification or if there are any additional details needed from my end.

    enter image description here

  • Vijay 13 posts 83 karma points
    Feb 19, 2024 @ 14:55

    Hello everyone,

    Does anyone have any idea about it? Please let me know.

    Regards, Vijay

  • AJ Murray 6 posts 95 karma points
    Apr 23, 2024 @ 23:49
    AJ  Murray

    Just a small point but your reference to "English calendar format ("MM/dd/yyyy HH:mm:ss tt")" is not actually correct from an international perspective. That format is actually the oddball American format.

    The rest of the civilised world either uses the logical format going from smallest to largest (dd/MM/yyyy) or the universal format (yyyy/MM/dd).

    Standard Date and Time format strings

    And your site will need to take different cultures and timezones into account if you are using dates and times.Date conversion between time zones

    Usually the best approach is to store your dates in UTC format, and then convert them to the user's timezone and culture when displaying.

    The format "0001-01-01T00:00:00" is actually the value of an empty date/time field expressed in UTC format with timezone (that is the T in the middle). So it is not "unknown", just empty (MinDate) as there is no such thing as a null date.

    Remember that you will be likely dealing with 3 zones in the app:

    1. UTC time zone, baseline for everywhere in the world.
    2. Server timezone (which depends on where your site is hosted, cloud or on prem or vm)
    3. the user's timezone (which you may or may not know)

    And the culture of the app may be fixed by you, or you may allow the user to set it to whatever they like.

    The Umbraco app does not seem to automatically store dates in UTC format (some other cms's do this) so you have to choose that yourself.

    You need to make a choice about how to store the dates in your own app.

    When you define a date field, you can set the date format in the property editor. For example, a property with a Date/Time picker, click on the cog wheel to edit the property, then Edit the picker again and there you can set the date format.

Please Sign in or register to post replies

Write your reply to: