Javascript examples for JSon:JSon String
Sorting JSON objects by timestamp
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w .j av a 2s. com var array = [{id: 1, date:'Mar 12, 2012 07:00:00 AM'}, {id: 2, date:'Mar 12, 2012 08:00:00 AM'}, {id: 3, date:'Mar 12, 2011 08:00:00 AM'}]; var sortedData= array .sort((function (a, b) { return new Date(b.date) - new Date(a.date) })); console.log(sortedData); } </script> </head> <body> </body> </html>