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;
};

  

最新文章

  1. 设置select默认值
  2. printf("%*s\n", 1, ""); 使用"printf();" 的格式化输出动态制定等宽度输出。
  3. Log4net使用笔记
  4. 图像分类之特征学习ECCV-2010 Tutorial: Feature Learning for Image Classification
  5. thinkPHP 无法create,无法插入数据,提示非法数据对象
  6. RPC框架motan: 通信框架netty( 1)
  7. PHP读书笔记(7)- 函数
  8. TP-Link WR842N VPN错误619 不能建立到远程计算机的连接
  9. Windows|Windows Server 2003单网卡搭建VPN
  10. 10分钟学会JAVA注解(annotation)
  11. Jquery使用mouseenter和mouseleave实现鼠标经过弹出层且可以点击
  12. Spring Boot 引入自定义yml
  13. angular2 学习笔记 ( 第3方插件 jQuery and ckeditor )
  14. further occurrences of HTTP header parsing errors will be logged at DEBUG level.错误
  15. 【一天一道LeetCode】#59. Spiral Matrix II
  16. java、php、.net关于web开发的区别
  17. mysql length和char_length
  18. 3 saltstack高可用
  19. oracle函数创建及调用
  20. C#反射机制详解

热门文章

  1. opencv用imread( argv[1], 1)读取图片
  2. 在heroku上部署gost代理服务端
  3. nginx 模块讲解
  4. 面向对象的JavaScript
  5. Android中View的事件分发机制
  6. java 排序
  7. java常用注释
  8. HTML 5 <script> 标签
  9. sql server数据库连接问题处理
  10. Java反射机制专题