full-calendar start date today

谁都会走 提交于 2019-12-02 18:39:45

问题


I am trying really hard to make full-calendar to start from today. What it does is it displays the full week when I do this:-

$('#calendar').fullCalendar({
  // Options
});

$('#calendar').fullCalendar('gotoDate', currentDate);

where currentDate is today.

Refernce:- http://flickfootball.in/ click on calendar tab..


回答1:


FullCalendar depends on moment.js, so you can do:

var today = moment().day();
$('#calendar').fullCalendar({
  firstDay: today
});



回答2:


<script>
  $('#calendar').fullCalendar({
    defaultDate: moment().format("YYYY-MM-DD")
  });
</script>



回答3:


add below code

$('#my-today-button').click(function() {
  $('#calendar').fullCalendar('today');
});

For more information check link




回答4:


Refer this link

How to show description of Events in fullcalendar

// i am using moment.js for taking a date as today - today_date = moment().format('YYYY-MM-DD');

// in this line i am giving default date as today. - defaultDate: today_date,




回答5:


Set the defaultDate like so:

$('#calendar').fullCalendar('today')

Example

$('#calendar').fullCalendar({
        header: {
          left: 'prev,next today',
          center: 'title',
          right: 'month,agendaWeek,agendaDay,listYear'
        },
        defaultDate: $('#calendar').fullCalendar('today'),  // THIS IS WHAT YOU'RE LOOKING FOR
        nowIndicator: true,
        navLinks: true, // click day/week names to navigate to date
        editable: true, // allows drag/drop
        eventLimit: true, // allow "more" link when too many events
        events: [] //an array of your events here
});

More in the documentation for getting the current day here




回答6:


$(function() {
    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        defaultDate: moment(), //Use moment() as current date
        editable: true,
        eventLimit: true, // allow "more" link when too many events

    });
});



回答7:


you can use php

first you need set time to use

<?php
date_default_timezone_set('America/Manaus'); 
$today = date("Y-m-d");//use this format
?>

second, call variable in fullcalendar

<script>
$(document).ready(function() {

        $('#calendar').fullCalendar({
            defaultDate:   <?php echo "'" . $today . "'"; ?>,//yyyy+"-"+mm+"-"+dd,
                                });
                          });
</script>



回答8:


Do you want like this Try this

$(function() {
	$('#calendar').fullCalendar({
		header: {
			left: 'prev,next today',
			center: 'title',
			right: 'month,agendaWeek,agendaDay'
		},
		defaultDate: '2016-01-12',
		editable: true,
		eventLimit: true, // allow "more" link when too many events
		
	});
});
<link rel='stylesheet' href='http://fullcalendar.io/js/fullcalendar-2.6.1/fullcalendar.min.css' />
<script src='//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js'></script>
<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://fullcalendar.io/js/fullcalendar-2.6.1/fullcalendar.min.js'></script>
<link rel='stylesheet' href='http://fullcalendar.io/js/fullcalendar-2.6.1/fullcalendar.min.css' />
<div id='calendar'></div>



回答9:


Found an hack. Though not a proper solution.

Full-calendar allows you to start your calendar with firstDay: ''. So just find out which day is it today and set that to firstDay. So calendar starts from that date.

var d = new Date(); var t = d.getDay();

firstDay: t,



来源:https://stackoverflow.com/questions/36688063/full-calendar-start-date-today

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!