Narendra Rajput
Narendra Rajput

Reputation: 711

Covert Time Returned by Facebook Graph API to readable Time Format

I m getting Time data in this format in an JSON Object.

 "created_time": "2012-04-01T15:02:52+0000"

I need to convert this format to some readable time format like

 3:02 PST 1 April, 2012 

So the users understand it. I m using Jquery for handling this data. I tried doing it but I m not understanding which time format it is !

Upvotes: 2

Views: 3721

Answers (2)

Eric Lennartsson
Eric Lennartsson

Reputation: 589

You should be able to do something like this, which should actually be human readable:

var date = new Date("2012-04-01T15:02:52+0000")
console.log(date); //Sun Apr 01 2012 17:02:52 GMT+0200 (W. Europe Summer Time) 

Using the Date object, you are able to convert it further, should you want.

See http://www.elated.com/articles/working-with-dates/ for some nice examples, like:

date.toDateString(); //Sun Apr 01 2012​​​​​​​​​​​​​​​​​

Upvotes: 7

Viren Rajput
Viren Rajput

Reputation: 5736

I guess you want Timeago plugin !

Upvotes: 0

Related Questions