Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Parse string into Date in angularjs

I have data from the server to display. I receive strings such as this: 2016-05-01. I need to filter the data between two dates in that format. I have a function to parse the date as it is:

$scope.parseDate = function (date) {
  return new Date(Date.parse(date));
} 

In my html I display the date with this:

{{ parseDate(item.startDate) }}`

But in the browser, the result is: "2016-07-12T00:00:00.000Z".

  1. I need the parse the string into the same format as from the server: 2016-05-01.

  2. I need a simple filter function.

I don't want to use moment.js. My backend platform is JavaScript.

like image 832
KK SK Avatar asked Dec 18 '22 04:12

KK SK


1 Answers

Try this in your html :

{{item.startDate | date: 'MMM dd, yyyy'}}
like image 63
Chandru Avatar answered Dec 24 '22 02:12

Chandru