I am wanting to covert this "T" type of code
8/26/2016 9:02:15 AM
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'); d.setUTCMinutes(d.getUTCMinutes(d)+60*7-d.getTimezoneOffset()); 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.