Date not sorting properly according to time

Posted by: parmarkinjalk on 17 May 2020, 4:21 pm EST

  • Posted 17 May 2020, 4:21 pm EST

    Hi Team,

    I am creating date object for one of the columns and sorting on that column. It is sorting properly based on date but not sorting properly based on time. Looks like when it comes to time it is sorting based on string and not actual time. For E.g- 1/1/2020 2PM show after 1/1/2020 9 AM when sorting for latest first.

    element.modifiedDate = formatDate(element.modifiedDate, 'yyyy/MM/dd hh:mm', 'en-US');
    element.modifiedDate = new Date(element.modifiedDate)


    in the above code modified date is a string which I am formatting it as 'yyyy/MM/dd hh:mm' and changing it to date object.
  • Replied 17 May 2020, 4:23 pm EST

    Let me know if there is a way to sort it based on date as well as time. Thanks.
  • Replied 18 May 2020, 4:13 pm EST

    Hi Kinjalk,

    We are sorry but we were unable to replicate the issue at our end. Please refer to the link below that we used to replicate the issue:

    https://stackblitz.com/edit/angular-yqycqe

    Can you please let us know whether we are missing something in order to replicate the issue?

    Regards,
    Ashwin
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels