Questions & Answers

Format date events to dd-mm-yyyy in fullcalendar

I have a database, where there dates who are in format like 21-01-2023 but fullcalendar read dates like 2023-01-20.

I would like to read dates events like 21-01-2023 14:55.

I set lang to fr but just change the language not the the format date.

Any advice or tips would be appreciate.


there is example code of what i want to (see the third events example please) the sample code :

    <link rel="stylesheet" href="//"/>

    <h2>Translate FullCalendar v2</h2>
    <div id="calendar"></div>
    <script src="//"></script>
    <script src="//"></script>

    <script src="//"></script>
    <script src="//"></script>

          lang: 'fr',
                events: [
                          title: 'All Day Event',
                          start: '2023-01-01'
                          title: 'Long Event',
                          start: '2023-01-07',
                          end: '2023-01-10'
                          title: 'Long Event in my format date i want',
                          start: '20-01-2023',
                          end: '21-01-2023'

2023-01-21 23:01:20
in javascript while assigning value you can use str.split('-').reverse().join('-') to change format
2023-01-21 23:01:20
Are the dates in your database stored as strings (varchar)? Or are they stored as DATE or DATETIME? If the latter, they are not stored formatted in a specific way. If the former, convert to the latter.
Answers(0) :