0

I'm developing a website and I'm trying to get created_time from Facebook's JSON. I was successful in that and I got it as 2018-04-17T17:25:23+0000.

Now this should be converted into other format like 2018/04/17 5:23pm

My challenge now is to convert that into other format.

Please help me to convert the string formatted time from JSON object to another date format.

chanafdo
  • 5,016
  • 3
  • 29
  • 46
Admee
  • 3
  • 2

2 Answers2

0

Try this

var date = new Date('2018-04-17T17:25:23+0000');
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
var new_format = month  + '/' + day  + '/' + year; // format :m/d/y

More information

Ryuk Lee
  • 720
  • 5
  • 12
0

With your example date above, you can simply create a javascript date object like var date = new Date('2018-04-17T17:25:23+0000'); and use this for creating any specific date formats.

See How to get current formatted date dd/mm/yyyy in Javascript and append it to an input for creating a new format

Patrick M
  • 113
  • 1
  • 7