如何格式化JSON日期? [英] How to format JSON date?

查看:151
本文介绍了如何格式化JSON日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我需要格式化这种格式的JSON日期

so, i need format JSON date from this format

9/30/2010 12:00:00 AM,它是 MM / DD / YYYY HH:MM:SS 格式如下: DD / MM / YYYY ,所以我不需要关于小时,分钟和秒的信息,我需要更换json的月和日,我尝试了一些不同的方法,但总是失败

"9/30/2010 12:00:00 AM", it is MM/DD/YYYY HH:MM:SS to format like this : DD/MM/YYYY, so i dont need info about hours, min and sec, and i need replace months and days from json, i tried some different ways but it always failed

我需要使用 jQuery

我也没有找到任何答案来形成这个日期类型,所有我发现的形成日期是这样的: /日期(1224043200000)/

also i didnt find any answer to formating this date type, all i found was formating date like this :/Date(1224043200000)/

所以任何人都有想法?

推荐答案

你可以从字符串中创建一个Date对象:

you can create a Date Object from a string like so:

var myDate = new Date(dateString);

然后你可以随意操纵它,获得你想要的输出的一种方法是:

then you can manipulate it anyway you want, one way to get your desired output is:

var output = myDate.getDate() + "\\" +  (myDate.getMonth()+1) + "\\" + myDate.getFullYear();

您可以在此处找到更多信息 elated.com文章使用日期

you can find more at this elated.com article "working with dates"

这篇关于如何格式化JSON日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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