JS时间格式化
来源:互联网 发布:晒书房 知乎 编辑:程序博客网 时间:2024/06/16 06:29
//时间格式化函数
function jsonDateFormat(jsonDate) {//json日期格式转换为正常格式
try {
console.log("开始格式化交易日期:"+jsonDate);
//var date = new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10));
var date = new Date(parseInt(jsonDate, 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
//var hours = date.getHours();
//var minutes = date.getMinutes();
//var seconds = date.getSeconds();
return date.getFullYear() + "-" + month + "-" + day;
} catch (ex) {//出自http://www.cnblogs.com/ahjesus 尊重作者辛苦劳动成果,转载请注明出处,谢谢!
return "";
}
}
function jsonDateFormat(jsonDate) {//json日期格式转换为正常格式
try {
console.log("开始格式化交易日期:"+jsonDate);
//var date = new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10));
var date = new Date(parseInt(jsonDate, 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
//var hours = date.getHours();
//var minutes = date.getMinutes();
//var seconds = date.getSeconds();
return date.getFullYear() + "-" + month + "-" + day;
} catch (ex) {//出自http://www.cnblogs.com/ahjesus 尊重作者辛苦劳动成果,转载请注明出处,谢谢!
return "";
}
}
阅读全文
0 0
- 【js】js时间格式化
- js中格式化时间
- js时间日期格式化
- js 格式化时间
- js 格式化时间函数
- js格式化时间
- js 格式化时间
- js时间格式化
- js中格式化时间
- js 格式化时间
- js的时间格式化
- js 时间格式化
- js格式化时间
- js时间格式化
- js字符串格式化时间
- js 时间格式化
- 用js格式化时间
- js 时间格式化
- java设计模式之单例模式
- STM32 F4 从bootloader跳转用户代码遇到的问题
- Jekyll博客添加RSS feed订阅功能
- tensorflow学习fully_connected_feed.py
- JavaScript、Ajax与jQuery的关系
- JS时间格式化
- php的配置和安装-index.php
- 100行代码入门Scala
- SQL的一些操作
- XCTF嘉年华 re1 Writeup
- js内置方法的两种不同操作方式
- js java 运算符优先级用法总结
- js复制文字
- es6 之 Generator(一)