Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 936603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:20:29+00:00 2026-05-15T21:20:29+00:00

So I have this array: $dates[0] = array(‘start’=>’2010-07-22’, ‘end’=>’2010-07-23’); $dates[1] = array(‘start’=>’2010-07-22’, ‘end’=>’0000-00-00’); $dates[2]

  • 0

So I have this array:

$dates[0] = array('start'=>'2010-07-22', 'end'=>'2010-07-23');
$dates[1] = array('start'=>'2010-07-22', 'end'=>'0000-00-00');
$dates[2] = array('start'=>'2010-07-29', 'end'=>'0000-00-00');
$dates[3] = array('start'=>'2010-07-31', 'end'=>'2010-07-31');
$dates[4] = array('start'=>'2010-07-08', 'end'=>'2010-07-31');
$dates[5] = array('start'=>'2010-08-01', 'end'=>'2010-09-30');
$dates[6] = array('start'=>'2010-07-18', 'end'=>'2010-08-15');
$dates[7] = array('start'=>'2010-07-01', 'end'=>'2010-08-31');

and i have the following condition:
if an element 'start' is less then today, took the element's attribute 'end' and position the element relative to the others elements 'start'

So if an event started yesterday and ends tomorrow it should appear after the events beginning today

so the resulting array is something like this:

$dates[3] = array('start'=>'2010-07-22', 'end'=>'2010-07-23');
$dates[4] = array('start'=>'2010-07-22', 'end'=>'0000-00-00');
$dates[5] = array('start'=>'2010-07-29', 'end'=>'0000-00-00');
$dates[6] = array('start'=>'2010-07-31', 'end'=>'2010-07-31');
$dates[1] = array('start'=>'2010-07-08', 'end'=>'2010-07-31');
$dates[7] = array('start'=>'2010-08-01', 'end'=>'2010-09-30');
$dates[2] = array('start'=>'2010-07-18', 'end'=>'2010-08-15');
$dates[0] = array('start'=>'2010-07-01', 'end'=>'2010-08-31');

How could i go from the sample input to the sample output?

[EDIT]

  1. I’m trying to change the output of EventList a component for Joomla
  2. I’m not a native english speaker

So, I’ll try again:

if the event start date is minor than today then order the event relative to this event enddate and the others events startday

Ex:

If the event ‘A’ started on 2010-07-01 and finish on 2010-07-25 and event ‘B’ starts on 2010-07-24 and the current date is 2010-07-20 then event ‘A’ comes after event ‘B’

If the event ‘A’ starts on 2010-07-20 and finish on 2010-07-25 and event ‘B’ starts on 2010-07-24 and the current date is 2010-07-20 then event ‘B’ comes after event ‘A’

I ‘hope’ it’s a little more clearer now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:20:30+00:00Added an answer on May 15, 2026 at 9:20 pm

    Hmmm, so if I understand correctly: sort by stardate if >=today, enddate if startdate <= today.

    function _myDateSorter($a,$b){
        $date = date('Y-m-d');
        $adate = ($a['start'] >= $date) ? $a['start'] : $a['end'];
        $bdate = ($b['start'] >= $date) ? $b['start'] : $b['end'];
        if($adate =='0000-00-00') $adate = '9999-99-99';//sort after it appears
        if($bdate =='0000-00-00') $bdate = '9999-99-99';//sort after it appears
        if($adate == $bdate) return 0;
        return $adate > $bdate ? 1 : -1;
    }
    
    uasort($dates,'_myDateSorter');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two dates of the form: Start Date: 2010-12-24 End Date: 2011-10-06 (today)
See i have this following code below, at line no.9 i'm calculating some dates
I have a javascript array of dates, in the form {year:'2010',month:'6',day:'23'} I need to
I have an array of dates whose format is like this: 10/15/2005 or 2/10/2011.
I have two dates - a start date and an end date. I need
Okay, so I have this array. Currently it pulls multiple payment amounts and dates
I currently have this code: $dates = array(); foreach($data['sc_event_dates'] as $date) { if($date >
I have this function to generate an array of dates between a range. I
Given the following array: var dates = ['2012-10-01', '2012-10-02', '2012-10-03', '2011-01-01', '2011-01-02', '2011-06-03', '2010-09-01',
I have two arrays: $item dates basicaly looks like this: Array ( [0] =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.