-1

I am working with full Calendar and passing this array to full calendar

[{"id":"11589","slot":"Morning",start: "2019-07-18T06:00:00",end: "2019-07-18T09:00:00"},{"id":"11590","slot":"Afternoon",start: "2019-07-18T00:00:00",end: "2019-07-18T00:00:00"},{"id":"11588","slot":"Evening",start: "2019-07-18T17:00:00",end: "2019-07-18T18:15:00"},{"id":"11587","slot":"Night",start: "2019-07-18T20:15:00",end: "2019-07-18T22:15:00"}]

the issue is i want to show event of day in this order only but what i want is afternoon is coming first then Morning, Evening & Night.

Output :

Afternoon 
Morning 
Evening 
Night 

Required Output:

Morning 
Afternoon
Evening 
Night 
user3653474
  • 3,393
  • 6
  • 49
  • 135
  • 1
    So do you want Afternoon first? Or 2nd, as in the "required output"?? If you want the required output, just add proper beginning and end times to the event (right now, both are 0:00). –  Jul 30 '19 at 11:04
  • he wants morning first. he has afternoon first now, because timestamps/date are not set correctly i guess – Ionut Ardelean Jul 30 '19 at 11:05
  • @IonutArdelean quote: `but what i want is afternoon is coming first ` –  Jul 30 '19 at 11:07
  • @ChrisG to be honest i looked at current Output and Required Outpus. – Ionut Ardelean Jul 30 '19 at 11:08
  • @IonutArdelean See my first comment... OP is contradicting himself within the question –  Jul 30 '19 at 11:09
  • 1
    How do you expect a *calendar* to sort an event with a time of 00:00 after an event that is 8 hours later? How is that supposed to work, ever? Where exactly do you want `afternoon` displayed in the day view? –  Jul 30 '19 at 11:10
  • @Chris G: I want Morning first and then Afternoon, is there any way to achieve the reuired output without passing time as a parameter to calendar. – user3653474 Jul 30 '19 at 11:11
  • if you use dates without hours, minutes, etc, and just use the date as in year month and day, they will all have the same hour, therefor will represent the same value. – Ionut Ardelean Jul 30 '19 at 11:12
  • If you want Afternoon between Morning and Evening, assign Afternoon a time between Morning and Evening. If you can't use a time for Afternoon for whatever reason, you cannot use fullcalendar. Please explain why you cannot add a time to the Afternoon event. –  Jul 30 '19 at 11:13

1 Answers1

2

your problem lies in your data from your input array.

[{"id":"11589","slot":"Morning",start: "2019-07-18T06:00:00",end: "2019-07-18T09:00:00"},{"id":"11590","slot":"Afternoon",start: "2019-07-18T00:00:00",end: "2019-07-18T00:00:00"},{"id":"11588","slot":"Evening",start: "2019-07-18T17:00:00",end: "2019-07-18T18:15:00"},{"id":"11587","slot":"Night",start: "2019-07-18T20:15:00",end: "2019-07-18T22:15:00"}]

Afternoon has a lower timestamp that morning, that's why it comes first. if you switch the dates, especially the hours are important here, then everything works fine, see below:

[{"id":"11589","slot":"Morning",start: "2019-07-18T00:00:00",end: "2019-07-18T00:00:00"},{"id":"11590","slot":"Afternoon",start: "2019-07-18T06:00:00",end: "2019-07-18T09:00:00"},{"id":"11588","slot":"Evening",start: "2019-07-18T17:00:00",end: "2019-07-18T18:15:00"},{"id":"11587","slot":"Night",start: "2019-07-18T20:15:00",end: "2019-07-18T22:15:00"}]
Ionut Ardelean
  • 478
  • 4
  • 9
  • @lonut Ardelean: But i want it in sequence is there any other way to work with that. It is compulsory for me to pass 00:00 in afternoon slot. I can't pass time to it. – user3653474 Jul 30 '19 at 11:05
  • well if you want to use those dates as the way of sorting these items, then it is important to use your date objects correctly 0 hour will always come before 9. you already pass time in those dates. the dates with hours i took from you example, i did not add them. – Ionut Ardelean Jul 30 '19 at 11:06