Jump to content

Recommended Posts

Hi, I have a series of dates in the following format to display in a graph.  I've managed to convert the dates to dd-mm-yyyy but want to sort the array by date..

The date is originally pulled from an email in the format "30 November 2009" then placed into a db in separate columns 'day', 'month', 'year'  so the my array would originally look like this:

 

$datetosort[] = "30 November 2009";
$datetosort[] = "24 November 2009";
$datetosort[] = "23 November 2009";
$datetosort[] = "20 November 2009";
$datetosort[] = "9 December 2009";
$datetosort[] = "5 December 2009";
$datetosort[] = "3 December 2009";
$datetosort[] = "1 December 2009";

foreach($datetosort as $correctDate){
$value[] = date('d-m-Y',strtotime($correctDate)); 
}

print_r($value);

 

changed format is like this in array:

 

Array ( [0] => 30-11-2009 [1] => 24-11-2009 [2] => 23-11-2009 [3] => 20-11-2009 [4] => 09-12-2009 [5] => 05-12-2009 [6] => 03-12-2009 [7] => 01-12-2009 )

 

now I want to sort into date order, any ideas?  Cheers  :-*

Link to comment
https://forums.phpfreaks.com/topic/195727-date-sort/
Share on other sites

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.