Jump to content

Filter from all events on $date and $date+1


LLeoun

Recommended Posts

Hi all,

 

I have a webpage with a list of events. The way I want to show them is to show the events that are happening right now  and the ones that will happen later in the day. The information comes in an xml file that changes every day.

 

Let me explain it with an example.

 

Today's xml has the following items:

 

08:30. Breakfast with today's writer

09:30. Readings

12:30. Lunch at the association

13:30. Bridge championship

14:00. Chess competition

14:30. New technologies conference

17:00. Football match

20:00. Dinner with the football team

22:00. Concert

 

I want to show the events that are taking place right now and the ones that will take place later in the day.

So if right now the time is 13:20 I would like to show :

 

12:30. Lunch at the association

13:30. Bridge championship

14:00. Chess competition

14:30. New technologies conference

17:00. Football match

20:00. Dinner with the football team

22:00. Concert

 

To achieve this,  I'm doing inside of the foreach loop that is reading the xml file:

 

$now = gmmktime($hour_now, $minute_now, $sec_now, $month_now, $day_now, $year_now);
$beginTimeStamp = gmmktime($hour, $minute, $sec, $month, $day, $year);
$endTimeStamp = $beginTimeStamp + $duration;


if ($now<=$endTimeStamp){
echo"...........";
}

 

And this is working until the time of the event is date+1. Let me show it with another example:

Let's say that today's events have the following starting hours:

06:00...

08:30...

09:30...

10:30...

14:30...

15:00...

17:00...

20:00...

20:45...

21:15...

22:15...

23:30...

00:30...

01:00...

05:00...

 

If the time now is 00:35 with the code above it will show the whole list and not just:

00:30...

01:00...

05:00...

as it should.

 

It happens the same if the hour now is 01,02,03,04 and 05. Works well when the hour now is 06 as the hour the first event in the list starts and with the hours later than that until 00 hour.

 

For it to work I'd have to use this:  00:35  as 24:35, 01:35 as 25:35  .. and 05:35 as 29:35 ..

 

How can I fix this? How can I filter from all events on $date and $date+1?

 

Thanks a lot

 

Link to comment
Share on other sites

I don't get it, is that I'm not using a timestamp already here:

 

$now = gmmktime($hour_now, $minute_now, $sec_now, $month_now, $day_now, $year_now);
$beginTimeStamp = gmmktime($hour, $minute, $sec, $month, $day, $year);

 

thanks again

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.