FullCalendar Date and Time Processing

I am using the FullCalendar script and I am having problems formatting the date / time of the EVENTS in the calendar.

I need all the date / time data to look like this:

2011-09-28 08:15:00

All dates are similar to this in my JSON source, which displays correctly on the calendar. However, if the event is moved or a new event is added (discarded by perpetual drag), the time format is as follows:

Fri 30.09.2011 14:30:00 GMT-0400 (EDT)

This is not DISPLAY in this format, but it appears this way when I try to insert event.start or event.end in my database or when I do this:

eventClick: function(event) { alert("Event ID: " + event.id + " Start Date: " + event.start + " End Date: " + event.end); } 

I use this only to see how the date and time are stored in the calendar. I need to update my database with new events, but in the format shown above, but I am having problems with this.

How to use formatDate function? I see him on the list, and the reason I'm asking for is because I don’t know what to do about it.

I did:

 $.fullCalendar.formatDate(event.start, 'MM-dd-yyyy'); 

but it does nothing ...

+6
source share
7 answers

what I did was, first put it in var, but it only seemed to work in IE - FF, still creating the IETF format (for example: "Wed, 18 Oct 2009 13:00:00 EST"):

 var formDate = $.fullCalendar.formatDate(event.start, 'MM-dd-yyyy'); alert(" Start Date: " + formDate); 
+2
source

Just use the following code before rendering events:

 start=moment(start).format('YYYY/MM/DD hh:mm'); 

 end=moment(end).format('YYYY/MM/DD hh:mm'); 

Make sure you use moment.js.

+9
source

Check out formatDate and parseDate and this will probably solve your problems.

0
source

Q: How to use the formatDate function? I see him on the list, the reason I'm asking for is because I don’t know what to do with it. I did: $ .fullCalendar.formatDate (event.start, 'MM-dd-yyyy'); It does nothing ...

Answer:

You can use look like:

 eventClick: function(event) { alert("Event ID: " + event.id + " Start Date: " + $.fullCalendar.formatDate(event.start, 'MM-dd-yyyy') + " End Date: " + event.end); } 
0
source

I found your answer in a similar question in here

Answered by HD:

 dateStr = "Tue Aug 13 2013 18:00:00 GMT-0400 (EDT)" (new Date(dateStr)).toISOString().slice(0, 10) 

It will display: '2013-08-13'

 (new Date(dateStr)).toISOString() 

It will display: '2013-08-13T18: 00: 00.000Z'

0
source

If you are trying to transfer a date object from java to a full calendar and using Java 7 or less, the function below will work for you.

Date Date = New Date ("passyourdatestring");

date.toLocaleString ();

And then there will be an event object.

{

 id: '_jobName' , url: 'url ', title: 'title', allDay: 'false', description: 'displayname', start': 'schedDateTime', end: date.toLocaleString() 

};

0
source

I used the code below when rendering an event on a calendar.

We hope this code helps you.

  eventRender: function(event, element) { eventsdate = moment(event.start).format('hh:mm a'); eventedate = moment(event.end).format('hh:mm a'); element.find('.fc-time').html(eventsdate + " - " + eventedate + "<br>"); } 

Make sure you use moment.js

0
source

Source: https://habr.com/ru/post/898288/


All Articles