Jump to content

Recommended Posts

Hello, I am quite new in PHP.

 

I am doing a page with list of events (seminars).

The events are saved in a XML file in chronological order and their each event has its date in d-m-Y format and time in h:m format.

What I need to do is find the next event (with respect to the actual date and time).

I can do it using a loop (foreach) and stringtotime() and comparing obtained values. However, this seems to be quite a clumsy way.

Is there any better way to do it? Maybe there is a function, package or some extension, which I don't know...  :shrug:

 

I tried xpath, however it does not know how to compare the dates (I use xml 1.0).

 

Thank you very much.  :)

 

Link to comment
https://forums.phpfreaks.com/topic/249139-searching-for-next-event-in-a-list/
Share on other sites

The problem here is the xml file.  If it were a database, you would have date functions to help you pull only the valid info.  Being that it is xml, I don't know of a way for you  to check dates, other than looping the data, until you find the one that you want.

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.