0

How to convert Date format (19-Jan-2018) to ( Friday, 19 Jan 2017) using angularjs. I used below method and sortdate should return value in format DD, d MM yyyy.

var sortdate = dateConvertions(service.date); console.log(sortdate);

    function dateConvertion(s)
    {
        var dateparts = s.split('-')
        return new Date(dateparts[2], dateparts[1]-1, dateparts[0]);
    } 
user3793029
  • 135
  • 3
  • 13
  • are you wanting to change how the date is displayed onscreen? – mast3rd3mon Feb 01 '18 at 16:04
  • 1
    try javascript date formatting or angularjs date pipe – Aniruddha Das Feb 01 '18 at 16:04
  • angularjs has date filters: `return $filter('date')(new Date(s),'DD, d MM yyyy');`. or you can try to be fancy with [moment.js](https://momentjs.com/) – Aleksey Solovey Feb 01 '18 at 16:06
  • It's already answered https://stackoverflow.com/questions/4822852/how-to-get-the-day-of-week-and-the-month-of-the-year – Gowthaman Feb 01 '18 at 17:02
  • Possible duplicate of [*Where can I find documentation on formatting a date in JavaScript?*](https://stackoverflow.com/questions/1056728/where-can-i-find-documentation-on-formatting-a-date-in-javascript) – RobG Feb 01 '18 at 20:27
  • You'r effecively passing `"Jan" - 1` as the month value, which isn't going to work. – RobG Feb 02 '18 at 00:26

0 Answers0