Coding Away Coding Away - 1 month ago 8x
AngularJS Question

Angular with Javascript convert ( 2016-08-26T16:02:15.747 ) to m/d/yyyy hh:mm:ss am/pm 8/26/2016 9:02:15 AM

I am wanting to covert this "T" type of code



I gather that is

NEED TO convert with javascript to

8/26/2016 9:02:15 AM

( so I assume its like m/d/yyyy hh:mm:ss am/pm somehow )

I was looking at


If your time zone is GMT-07, then this will work:

var str = new Date('2016-08-26T16:02:15.747').toLocaleString('en-US');

Edit: As in comments you indicate your time zone is Arizona, the above will do. Arizona is GMT-07.

But if you are in another time zone, you'd need to provide that time zone as the second argument to toLocaleString. But as support for that is very limited, you could try to get around that by modifying the date based on your time zone:

d = new Date('2016-08-26T16:02:15.747');
s = d.toLocaleString('en-US');

However, this still may be 1 hour off when daylight saving is in effect.

... You probably would benefit from using momentjs which has many useful functions for dealing with this kind of manipulation.