0

I am getting date from backend which contains 'T' literal init.

'2017-02-20T15:30:44'

Can you help me how to format this in angular 2.

Green Computers
  • 597
  • 2
  • 12
  • 22
  • 1
    Possible duplicate of [How to format a JavaScript date](http://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date) – n00dl3 Apr 05 '17 at 07:20
  • 1
    Duplicate of http://stackoverflow.com/questions/5619202/converting-string-to-date-in-js and the question doesn't specify what format the author wants to get. Just a bit of googling would give the answer. – Ján Halaša Apr 05 '17 at 07:23
  • Possible duplicate of [Converting string to date in js](http://stackoverflow.com/questions/5619202/converting-string-to-date-in-js) – AJT82 Apr 05 '17 at 08:17

2 Answers2

1

There is nothing related to angular2 with date format you can simply do this using pure javascript like this

new Date('2017-02-20T15:30:44')).toLocaleString()

Working Plunker

Pardeep Jain
  • 71,130
  • 29
  • 141
  • 199
0

You can format in HTML as well as in typescript.

In .ts file:

let dateString = '1968-11-16T00:00:00' 
let newDate = new Date(dateString);

In HTML:

{{dateString |  date:'MM/dd/yyyy'}}