javascript - Covert Time Returned by Facebook Graph API to readable Time Format - Stack Overflow

I m getting Time data in this format in an JSON Object."created_time": "2012-04-01T15:02

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 !

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 !

Share asked Apr 2, 2012 at 7:54 Narendra RajputNarendra Rajput 7119 silver badges29 bronze badges 2
  • 3 What have you tried? – PeeHaa Commented Apr 2, 2012 at 7:56
  • I simply tried converting it simply by slicing the data and doing it manually ! But thats not a very efficient method. – Narendra Rajput Commented Apr 2, 2012 at 7:58
Add a ment  | 

2 Answers 2

Reset to default 7

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./articles/working-with-dates/ for some nice examples, like:

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

I guess you want Timeago plugin !

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745054992a4608608.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信