0

When my FullCalendar (v 2.3.1) attempts to get its event data in my Controller code, start and end parameters object looks like this:

start=1425186000
end=1428811200

The documentation states that I should be getting ISO8601 dates as the parameters but obviously I am not.

How do I get the FullCalendar to provide ISO8601 dates? What are the numbers that I am actually getting?

teo van kot
  • 12,350
  • 10
  • 38
  • 70

1 Answers1

1

That is the UNIX timestamp, and in your case represents March 1, 2015 (start) to April 12, 2015 (end).

A Unix timestamp (or epoch time) is the number of seconds that have elapsed since January 1, 1970 00:00 UTC. src

You can get either convert the unix timestamp (shown below) or the better solution would be to simply feed the ISO date to the calendar. This SO post discusses how to convert a DateTime to ISO.

$('#fullCal').fullCalendar({
  events: [{
    title: 'Random Event',
    start: moment().add(1, 'h'),
    end: moment().add(2, 'h'),
    allDay: false
  }, {
    title: 'Your Event Unix... No work!', //this is probably what your current code is doing
    start: 1425186000,
    end: 1428811200,
    allDay: false
  }, {
    title: 'Your Event Unix... work!', //this will work
    start: moment.unix(1425186000),
    end: moment.unix(1428811200),
    allDay: false
  }],
  header: {
    left: '',
    center: 'prev title next today',
    right: ''
  },
  timezone: 'local'
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.js"></script>

<div id="fullCal"></div>
Community
  • 1
  • 1
MikeSmithDev
  • 15,731
  • 4
  • 58
  • 89