Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

334
Views
Display all past data and hide all future data in javascript fullcalendar

As you can see in this javascript fullcalendar code, I want to display all past data in title and hide all future data in fullcalendar title.. the future data will show on its date. I'm beginner can you help me that how to hide future data in title. Thanks.

        var calendar = new FullCalendar.Calendar( calendarEl, {
         headerToolbar: {
               left:   'title',
               center: '',
               right:  'prev,next'
            },
             initialDate: '2022-04-01',
            dayMaxEvents: true, 
            events: [
                
                {
                    title: '8',
                    start: '2022-04-13',
                },
                {
                    title: '9',
                    start: '2022-04-14',
                },
                {
                    title: '6',
                    start: '2022-04-15',
                },
                {
                    title: '4',
                    start: '2022-04-18',
                },
                {
                    title: '6',
                    start: '2022-04-19',
                },
                    {
                    title: '3',
                    start: '2022-04-20',
                },
                {
                    title: '3',
                    start: '2022-04-21',
                },
                {
                    title: '3',
                    start: '2022-04-22',
                },
                {
                    title: '3',
                    start: '2022-04-25',
                },
                {
                    title: '3',
                    start: '2022-04-26',
                },
                {
                    title: '3',
                    start: '2022-04-27',
                }
            
    
                
            ]
        });
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use Array.prototype.filter to filter events starting after now.

var calendar = new FullCalendar.Calendar(calendarEl, {
    headerToolbar: {
        left: 'title',
        center: '',
        right: 'prev,next'
    },
    initialDate: '2022-04-01',
    dayMaxEvents: true,
    events: [
        {
            title: '8',
            start: '2022-04-13',
        },
        {
            title: '9',
            start: '2022-04-14',
        },
        {
            title: '6',
            start: '2022-04-15',
        },
        {
            title: '4',
            start: '2022-04-18',
        },
        {
            title: '6',
            start: '2022-04-19',
        },
        {
            title: '3',
            start: '2022-04-20',
        },
        {
            title: '3',
            start: '2022-04-21',
        },
        {
            title: '3',
            start: '2022-04-22',
        },
        {
            title: '3',
            start: '2022-04-25',
        },
        {
            title: '3',
            start: '2022-04-26',
        },
        {
            title: '3',
            start: '2022-04-27',
        }
    ].filter(event => new Date(event.start).getTime() < Date.now())
});

You can also refactor this operation into a function like so:

function filterFutureEvents(events) {
   return events.filter(event => new Date(event.start).getTime() < Date.now());
}

// usage
const fileteredEvents = filterFutureEvents([/* ... */]);
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!