locked
Get Previous and Next Month Dates RRS feed

  • Question

  • User194385433 posted
    Hi,
    
    
    How to get Next Month Date ,Month and Year when click on the Next Button on Calendar
    
    Sames as Previous Month Month,Date and Year when Click on the Previous Button on Calendar
    
    Below is the code:
    
    <div style="border:solid 2px red;">
            <div id='calendar'></div>
    </div>
    
    $(document).ready(function() {
    
        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();
    
        var events_array = [
            {
            title: 'Test1',
            start: new Date(2016, 6, 10),
            tip: 'Personal tip 1'},
        {
            title: 'Test2',
            start: new Date(2016, 7, 13),
            tip: 'Personal tip 2'}
        ];
    
        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            selectable: true,
            events: events_array,
            eventRender: function(event, element) {
                element.attr('title', event.tip);    
            }
        });
        
      $('.fc-button-prev span').click(function(){
    var prevDate = $("#calendar").fullCalendar('getDate').toDate();
    alert(prevDate); 
    });
    
     $('.fc-button-next span').click(function()
    {
    var nextMonthDate = $("#calendar").fullCalendar('getDate').toDate();
    alert(nextMonthDate);
    });
    
     });
    

    Wednesday, April 13, 2016 9:14 PM

Answers

All replies