I have a start_date of 1/10/2018, and an end_date of 1/8/2020, the difference between the two dates in months is 22, that is 1 year 10 months, now, I want to create tables that terminate at the end of each year as follows:
table 1
column_heading will be "1/10/2018 - 31/12/2018"
and the row will be "2 months"
table 2
column_heading will be "1/1/2019 - 31/12/2019"
and the row will be "12 months"
table 3
column_heading will be "1/1/2020 - 1/8/2020"
and the row will be "8 months"
I would like to loop something, maybe the difference between the dates to create the number of tables necessary, if the two dates exist within the same year it will only create 1 table, or 2 if it enters the next year, I am using laravel and carbon to manipulate the dates.
Thank you in anticipation of your help.
My Answer:
"Months from start_date to December" and the values will be:
1. October 2018 - December 2018 (3 months)
2. January 2019 - December 2019 (12 months)
3. January 2020 - December 2020 (1 month)
_table 2_column_heading will be "Months from January to end_date" and the values will be:
1. January 2019 - September 2019 (9 months)
2. January 2020 - August 2020 (8 months)
Rate this post
5 of 5 based on 8811 votesComments