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
2 Answers
Reset to default 7You 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 !