Sunday, June 2, 2024
31
rated 0 times [  35] [ 4]  / answers: 1 / hits: 8595  / 4 Years ago, thu, may 14, 2020, 12:00:00

I've been trying to change the format of the dates that appear in the day column headers on the Fullcalendar week/timegrid view:



enter



I'm using V5 in conjuction with moment.js.



Searching through the docs, I ended up here: https://fullcalendar.io/docs/v5/day-header-render-hooks



This is the code I've tried when initialising the calendar:



dayHeaderFormat: function(date){
return moment(date.weekday).format('ddd');
}


This results in showing today (Thu) for every header, rather than the correct days.



My next issue is that I'm not sure how to format the rest of the date accordingly - this targets the 'weekday' element of the date object, but I couldn't figure out how to format the whole date in one go (if that's possible). I'm looking to simply display 'Thu 14th', for example.



Any help or advice appreciated!


More From » fullcalendar

 Answers
1
dayHeaderContent: (args) => {
return moment(args.date).format('ddd Do')
}

The new function supplies args instead of date object. So you access them with args.date and then format using moment


[#3816] Tuesday, May 12, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cadendericki

Total Points: 482
Total Questions: 109
Total Answers: 103

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
;