LLeoun Posted June 7, 2010 Share Posted June 7, 2010 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 Quote Link to comment Share on other sites More sharing options...
syed Posted June 7, 2010 Share Posted June 7, 2010 You dont you use a timestamp instead? Convert the xml time to a timestamp and get the current timestamp? Quote Link to comment Share on other sites More sharing options...
LLeoun Posted June 7, 2010 Author Share Posted June 7, 2010 thanks for answering syed. In the xml I have the begin time in this format: 2010-06-07T06:00:00+02:00 how can turn that into a timestamp? Thanks again Quote Link to comment Share on other sites More sharing options...
ignace Posted June 7, 2010 Share Posted June 7, 2010 how can turn that into a timestamp? strtotime Quote Link to comment Share on other sites More sharing options...
LLeoun Posted June 7, 2010 Author Share Posted June 7, 2010 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.