Format Date to DD.MM.YYYY

Format Date to DD.MM.YYYY

r1adhbr1adhb Posts: 1Questions: 1Answers: 0

Hello everyone,

I am using datatable extracting data from an ajax file passing data with json and the date field is displayed like this:

a) without rendering -> /Date(1717107000000)/
b) DataTable.render.date() -> 31.5.2024
c) DataTable.render.datetime() -> 31.5.2024, 00:00:00
d) DataTable.render.datetime('DD.MM.YYYY') -> 30.05.2024

I want it to be displayed like in d), but for whatever reason it turns the 31st into the 30th (?!?).

Anyone have an idea about this?!

Answers

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    What timezone are you in please? It is almost certainly a timezone issue.

    If I run (this is what DataTable.render.date() basically does):

    moment.utc("/Date(1717107000000)/").toDate().toLocaleDateString() 
    

    I get:

    "30/05/2024"

    Are you able to have your server-side return ISO8601 formatted dates, rather than .NET epoch strings. That would take any uncertainty away.

    Allan

Sign In or Register to comment.