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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:37:13+00:00 2026-06-04T05:37:13+00:00

i did use var elems = $(#D li).toArray(); elems.sort(function(a, b) { var adate =

  • 0

i did use

var elems = $("#D li").toArray();
elems.sort(function(a, b) {
    var adate = new Date($(a).find('div.dateDiv').text());
    var bdate = new Date($(b).find('div.dateDiv').text());
    return adate > bdate ? -1 : 1;
});
$("#D").html(elems);

<div id="D">
    <li>1<div class="dateDiv">2012-04-15 10:25:45</div><div>df</div></li> 
    <li>2 <div class="dateDiv">2012-04-10 19:41:08</div><div>df</div></li> 
    <li> 3 <div class="dateDiv">2012-04-20 07:00:10</div><div>ab</div></li> 
    <li>4 <div class="dateDiv">2012-04-12 16:45:50</div><div>a</div></li>

     <li>1<div class="dateDiv">2012-04-15 10:25:45</div></li>
   <li>2 <div class="dateDiv">2012-04-10 19:41:08</div></li>
  <li> 3 <div class="dateDiv">2012-04-20 07:00:10</div></li>
   <li>4 <div class="dateDiv">2012-04-12 16:45:50</div></li>


      <li>1<div class="dateDiv">2012-04-15 10:25:45</div></li>
   <li>2 <div class="dateDiv">2012-04-10 19:41:08</div></li>
  <li> 3 <div class="dateDiv">2012-04-20 07:00:10</div></li>
   <li>4 <div class="dateDiv">2012-04-12 16:45:50</div></li>


      <li>1<div class="dateDiv">2012-04-15 10:25:45</div></li>
   <li>2 <div class="dateDiv">2012-04-10 19:41:08</div></li>
  <li> 3 <div class="dateDiv">2012-04-20 07:00:10</div></li>
   <li>4 <div class="dateDiv">2012-04-12 16:45:50</div></li>
</div>​

i try it many times
some problem with Firefox browser or IE or safari

it’s work only with opera and chrome ,

what the proper cross-browser date format is for passing to new Date() ?

  • 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-04T05:37:14+00:00Added an answer on June 4, 2026 at 5:37 am

    If you can control the date format in the HTML, then it would probably be best to convert it to a timestamp. Otherwise, you’d need to create a function in javascript to convert it to the proper format, whatever that might be.

    Instead of doing that, why not just split it up into it’s parts and pass the proper arguments to new Date() — year, month, day, hours, minutes, seconds.

    http://jsfiddle.net/katylava/xpjRa/2/

    function parseDate(date) {
        var date_time = date.split(' ');
        var ymd = date_time[0].split('-');
        var his = date_time[1].split(':');
        return new Date(ymd[0], ymd[1], ymd[2], his[0], his[1], his[2]);
    }
    
    var elems = $("#D li").toArray();
    elems.sort(function(a, b) {
        var adate = parseDate($(a).find('div.dateDiv').text());
        var bdate = parseDate($(b).find('div.dateDiv').text());
        return adate > bdate ? -1 : 1;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var someObject = { someArray : new Array(), someInt : 0, Total: function(){ this.someInt
What is the best way to rotate a image in asp.net I did use
I moved some hardcoded settings to a custom Section (so I did not use
The story: I had class User and class Organization: User. I did not use
I am working on my second multitenant MVC application. My first did not use
Why did some processor manifacturers decide to use Little endian Big endian Middle endian
I did the following steps to use the CDialog in win 32 application: Changed
I am trying to use some external Framework in my iPhone app. I did
I'm a Git user trying to use Mercurial. Here's what happened: I did a
I'm trying to use this http://www.rcsb.org/pdb/software/rest.do REST services with Qt. I did some get

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.