gpt4 book ai didi

javascript - 使用javascript将json字符串转换为dd-mm-yy格式的日期

转载 作者:行者123 更新时间:2023-11-28 17:44:02 25 4
gpt4 key购买 nike

我想将数据绑定(bind)在 dd-mm-yy 中我正在使用的格式 json绑定(bind)。目前我得到的日期为 2014-06-18T00:00:00

我想要dd-mm-yy格式。请让我知道如何做到这一点。

下面是我的代码。

if (getJSONValue.LAUNCH_DATE != "" || getJSONValue.LAUNCH_DATE == null) {
$('#txtLaunchDate').val(getJSONValue.LAUNCH_DATE);
}

我的getJSONValue.LAUNCH_DATE =2014-06-18T00:00:00

最佳答案

查看代码片段

var newDate = new Date("2014-06-18T00:00:00");
var day = newDate.getDate();
var month = newDate.getUTCMonth() + 1;
var year = newDate.getFullYear();
console.log(day + "-" + ("0" + (month)) + "-" + year );

关于javascript - 使用javascript将json字符串转换为dd-mm-yy格式的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47223821/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com