Hi everyone,
I have to implement bus time table in this way:
Every bus drives every second day from the day chosen.
Let's say: If xx bus goes every second day from 23rd February to 30th June to Spain (23rd, 25th, 27th...),
How can I check if let's say on 14th May there is bus to Spain?
I started with odd and even numbers: if it starts from the even day than there is array of months with number of days, but what if Feb has 29days (every 4th year) instead of 28... I'm totally confused here.
Is there any other way of implementing this?
Bus schedule/timetable
Moderator: General Moderators
Re: Bus schedule/timetable
you may try DatePeriod class
Re: Bus schedule/timetable
Hi, thanks for your help.
I have mis-minded date functions.
The easiest way of implementing this is to calculate days between start date and the date you looking at, and then check if the result can be divided by 2
I have mis-minded date functions.
The easiest way of implementing this is to calculate days between start date and the date you looking at, and then check if the result can be divided by 2
Code: Select all
if(($days_difference % 2) == 0){
//the bus will run today
}else{
//the bus won't run today
}