0

I have a json object which containing many objects. one of the values is time. The problem is it is a string at the moment. How can i convert this to a date and then sort all the objects by this date and then place it into a new array?

the object

$json_string = 'http://95.85.11.40/wordpress/?page_id=20';

$jsondata = file_get_contents($json_string);
$obj = json_decode($jsondata, true);

This is a example of the value for key time:

April 20, 2014 10:13 am
user3423384
  • 667
  • 2
  • 8
  • 18
  • 2
    Put it into an array and then sort the array by that value. There's *lots* of examples of that here at Stack Overflow. – John Conde May 16 '14 at 18:55
  • Dont i need to change it to a date or something? – user3423384 May 16 '14 at 19:04
  • Yes, converting the date to a sortable format will be required but that [can also be found here as well](http://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php/23087239#23087239). – John Conde May 16 '14 at 19:06
  • Actually, here you go: http://stackoverflow.com/questions/23146068/how-do-i-sort-a-flat-json-by-date/23146089#23146089. That's 95% of what you have to do. – John Conde May 16 '14 at 19:07
  • The main problem here is i need to convert this April 20, 2014 10:13 am to something like this i guys 20/04/2014 10:13 – user3423384 May 16 '14 at 19:27
  • See the first link I posted – John Conde May 16 '14 at 19:29
  • Yes but i need to change this april 20, 2014 10:13 am to something like 20/04/2014 10:13 how can i do this – user3423384 May 16 '14 at 19:59
  • You *really* should read that [first link I posted](http://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php/23087239#23087239) – John Conde May 16 '14 at 21:59

0 Answers0