将String格式的Facebook JSON created_time转换为其他格式 [英] Convert Facebook JSON created_time of String format to other format

查看:65
本文介绍了将String格式的Facebook JSON created_time转换为其他格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网站,并试图从Facebook的JSON中获取created_time.我在那方面很成功,并获得了2018-04-17T17:25:23+0000.

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.

现在应将其转换为其他格式,例如2018/04/17 5:23pm

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

我现在的挑战是将其转换为其他格式.

My challenge now is to convert that into other format.

请帮助我将字符串格式的时间从JSON对象转换为另一种日期格式.

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

推荐答案

尝试一下

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

更多信息

这篇关于将String格式的Facebook JSON created_time转换为其他格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆