Link to home
Start Free TrialLog in
Avatar of Ralph Gould
Ralph GouldFlag for United States of America

asked on

PHP sort an array on "Last Modified Date" with multiple dates the same error

I am producing a web page with a list of miscellaneous PDF documents. I want the list to be ordered by the last modified date in descending order. The problem I have is that some of the documents end up with the same time stamp. Apparently, PHP converts these time stamps into a number key for sorting and cannot deal with duplicates and items are dropped. I'm not a PHP guru so not sure how to deal with this
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

We need some more information to help you here -- specifically the test data set. (SSCCE)

To understand how PHP works with DATETIME values, please read this article, carefully for understanding.  It's amazingly easy once you understand the details.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

PHP does not have anything inherent that can cause timestamps to be duplicates or cause items to be dropped.  There are standard programming practices that can prevent these sorts of problems.  Once we see the test data set, we can show you easy and dependable ways forward.
Avatar of Ralph Gould

ASKER

Ray:
you really don't need any test data. The issue is based on the windows file "Last Modified Date" of any document(s).
if you are interested in the issue, Take any number of documents with the exact same last modified date and sort them in an array in descending order.

if not I will be happy to award you all of the points since you are the first (and only) respondent.

Actually I solved the issue by creating a unique key from the date to ensure no dups.
Ciao!
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why did you give a marked-down grade?  Why not just post your solution and accept that as the answer?
http://support.experts-exchange.com/customer/portal/articles/481419