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

  • Home
  • SEARCH
  • 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 8182201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:46:57+00:00 2026-06-07T00:46:57+00:00

I am trying to sort an array in PHP by date and time which

  • 0

I am trying to sort an array in PHP by date and time which is in ISO 8601 format. I am still trying to grasp PHP and have tried many of the solutions on stack overflow and I am just not able to nail down the right function. Hopefully this is an easy answer and it will be helpful to others.

FYI, this array was generated by the Citrix API for GoToMeeting. I would like to sort the array based on startTime in the soonest time first in the list.

Here is what the array looks like using var_export with two results presented:

array (
 0 => stdClass::__set_state(
  array(
   'createTime' => '2012-07-03T19:36:58.+0000',
   'status' => 'INACTIVE',
   'subject' => 'Client 1',
   'startTime' => '2012-07-10T14:00:00.+0000',
   'conferenceCallInfo' => 'United States: xxxxx Access Code: xxxxx',
   'passwordRequired' => 'false',
   'meetingType' => 'Scheduled',
   'maxParticipants' => 26,
   'endTime' => '2012-07-10T15:00:00.+0000',
   'uniqueMeetingId' => 12345678,
   'meetingid' => 123456789,
  )
 ),
 1 => stdClass::__set_state(
  array(
   'createTime' => '2012-07-02T21:57:48.+0000',
   'status' => 'INACTIVE',
   'subject' => 'Client 2',
   'startTime' => '2012-07-06T19:00:00.+0000',
   'conferenceCallInfo' => 'United States: xxxxx Access Code: xxxxx',
   'passwordRequired' => 'false',
   'meetingType' => 'Scheduled',
   'maxParticipants' => 26,
   'endTime' => '2012-07-06T20:00:00.+0000',
   'uniqueMeetingId' => 12345678,
   'meetingid' => 123456789,
  )
 ),
)

My goal is to then output the array into html div’s using a foreach loop, this code is complete and works well but my sort is off 🙂

Thank you in advance for any help!

Steve

  • 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-06-07T00:46:58+00:00Added an answer on June 7, 2026 at 12:46 am

    You can implement any sorting technique you can think of if you wrap it in a callback and use usort() docs here

    inside your callback, you can use strtotime or similar, and do simple int comparisons.

    $myDateSort = function($obj1, $obj2) {
      $date1 = strtotime($obj1->startTime);
      $date2 = strtotime($obj2->startTime);
      return $date1 - $date2; // if date1 is earlier, this will be negative
    }
    usort($myArray, $myDateSort);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to sort an array. I have an array of data, where
I'm struggling with trying to sort an array of dictionaries. My dictionaries have a
For the last 3 days, I have been trying to sort an array, but
I'm trying to sort a simple array which only contains a few decimal numbers.
i have been over so many posts online trying to sort this.... i am
Trying to sort an array in PHP that is being populated from a CSV.
I'm trying to sort an array in PHP using a custom function, but it's
I'm trying to use PHP's ksort to sort this array: Array( [district_name] => District
I'm looking at http://www.php.net/manual/en/array.sorting.php as a reference. I'm trying to sort the $_POST by
I am trying to sort array with usort, but it doesn't work, What am

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.