/date(-62135596800000)转换正常格式的时间
2024-10-19 04:21:39
function formatDatebox(value) {
if (value == null || value == '') {
return '';
}
var dt = parseToDate(value); //关键代码,将那个长字符串的日期值转换成正常的JS日期格式
return dt.format("yyyy-MM-dd"); //这里用到一个javascript的Date类型的拓展方法,这个是自己添加的拓展方法,在后面的步骤3定义
} /*带时间*/
function formatDateBoxFull(value) {
if (value == null || value == '') {
return '';
}
var dt = parseDate(value);
return dt.format("yyyy-MM-dd hh:mm:ss");
} var parseDate = function (timeSpan) {
var timeSpan = timeSpan.replace('Date', '').replace('(', '').replace(')', '').replace(/\//g, '');
var d = new Date(parseInt(timeSpan));
return d;
}; //为Date类型拓展一个format方法,用于格式化日期
Date.prototype.format = function (format) //
{
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
};
if (/(y+)/.test(format))
format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
};
最新文章
- 设置select默认值
- printf(";%*s\n";, 1, ";";); 使用";printf();"; 的格式化输出动态制定等宽度输出。
- Log4net使用笔记
- 图像分类之特征学习ECCV-2010 Tutorial: Feature Learning for Image Classification
- thinkPHP 无法create,无法插入数据,提示非法数据对象
- RPC框架motan: 通信框架netty( 1)
- PHP读书笔记(7)- 函数
- TP-Link WR842N VPN错误619 不能建立到远程计算机的连接
- Windows|Windows Server 2003单网卡搭建VPN
- 10分钟学会JAVA注解(annotation)
- Jquery使用mouseenter和mouseleave实现鼠标经过弹出层且可以点击
- Spring Boot 引入自定义yml
- angular2 学习笔记 ( 第3方插件 jQuery and ckeditor )
- further occurrences of HTTP header parsing errors will be logged at DEBUG level.错误
- 【一天一道LeetCode】#59. Spiral Matrix II
- java、php、.net关于web开发的区别
- mysql length和char_length
- 3 saltstack高可用
- oracle函数创建及调用
- C#反射机制详解