Skip to Content
0
Former Member
Feb 17, 2015 at 11:08 PM

Converting date string received in json object to day-date-time-timezone format

1485 Views

Hello folks,

I am getting a json object with date: LAST_MODIFIED: "2015-02-05 23:03:50.1520000"

I am trying to convert it into this format: Thu Feb 05 2015 15:03:50 GMT-0800(Pacific Standard Time), where time 15:03:50 and Time zone will be based on user's location. I am unable to do so. Can anyone help in this regards?

I tried this:

var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern : "yyyy/MM/dd HH:mm" });

var parsedDate = new Date(dateFormat.parse("2015-02-05").getTime());

and I get Thu Feb 05 2015 00:00:00 GMT-0800 (Pacific Standard Time) as output.

I am unable to capture the time somehow, I tried a few things like adding the time to the date but no results like:

var parsedDate = new Date(dateFormat.parse("2015-02-05 23:03:50 ").getTime());

Any thoughts on how I can achieve the desired format?

Thanks

Prab