-1

In my database i am storing date in this format 2015-12-14 00:00:00(yy/mm/dd h:m:s).How can i convert this date into this format 14 dec 2015 in angularjs ?Here is the format of my angular data:

{{data.time_stamp}}
query
  • 531
  • 3
  • 7
  • 30

2 Answers2

3

First, store mysql date in a jscript date object:

var aux = "2015-12-14 00:00:00".split(/[- :]/);
var vdate = new Date(aux[0], aux[1]-1, aux[2], aux[3], aux[4], aux[5]);

Then, Angular code is quite simple and documented, for example:

{{vdate | date:'dd MMM yyyy'}}

Check official information here: https://docs.angularjs.org/api/ng/filter/date

Regards

manuelbcd
  • 3,106
  • 1
  • 26
  • 39
1

Use Angular's built in filter for dates. https://docs.angularjs.org/api/ng/filter/date

{{ date_expression | date : format : shortDate}}
lwalden
  • 813
  • 7
  • 11