jqGrid时间转换
colModel: [
{ label: '注册时间', name: 'createDate', index: 'create_date', width: 80, formatter:function(value,options,row){
return new Date(value).Format('yyyy-MM-dd HH:mm:ss');}}
],
增加Date的prototype:
javascript Date format(js日期格式化):
// 对Date的扩展,将 Date 转化为指定格式的String
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
// 例子:
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
调用: var time1 = new Date().Format("yyyy-MM-dd");
var time2 = new Date().Format("yyyy-MM-dd HH:mm:ss");
其他方式可以参考如下的博客:
http://blog.csdn.net/liangxw1/article/details/50921462
jqGrid时间转换的更多相关文章
- [jquery]将当前时间转换成yyyymmdd格式
如题: function nowtime(){//将当前时间转换成yyyymmdd格式 var mydate = new Date(); var str = "" + mydate ...
- MySQL 日期、时间转换函数
MySQL 日期.时间转换函数:date_format(date,format), time_format(time,format) 能够把一个日期/时间转换成各种各样的字符串格式.它是 str_to ...
- java时间类型的转换/获取当前时间/将时间转换成String/将String转换成时间
对于我的脑子,我已经服气了...写了N遍的东西,就是记不住...既然记不住那就记下来... 利用java获取当前的时间(String类型,年-月-日 时:分:秒) //我要获取当前的日期 Date d ...
- inner join ,left join ,right join 以及java时间转换
1.inner join ,left join 与 right join (from 百度知道) 例表aaid adate1 a12 a23 a3表bbid bdate1 ...
- Python基本时间转换
时间转换 python中处理时间的时候,最常用的就是字符形式与时间戳之间的转换. 把最基本的转换在这里记下来 string -> timestamp import time import dat ...
- Date类型时间转换
/* 时间转换start */ public static void main(String args[]) { Date nowTime = new Date(); System.out.print ...
- unix环境C编程之日期时间转换
1.理清概念 1.1.日历时间: 含义:国际标准时间1970年1月1日00:00:00以来经过的秒数. 数据类型:time_t.实际上是long的别名. 1.2.tm结构时间: 含义:结构 ...
- php时间转换unix时间戳
本文介绍了php编程中unix时间戳转换的小例子,有关php时间转换.php时间戳的实例代码,有需要的朋友参考下. 第一部分,php 时间转换unix 时间戳实现代码. 复制代码代码示例: <? ...
- Js 处理将时间转换 “年-月-日”
将时间 \/Date(1432828800000+0800)\/" 转换成:“年-月-日” //时间转换function ChangeDateFormat(val) { if (v ...
随机推荐
- 6491: Daydream
题目描述 You are given a string S consisting of lowercase English letters. Another string T is initially ...
- web服务搭建
- UVA 220 Othello
题意:输入n,代表次数,每次输入8*8的棋盘,处理3种命令:①L:打印所有合法操作,②M:放棋子,③Q:打印棋盘然后退出. 思路:①用字符数组存棋盘,整型数组存合法位置. ②查找的方法:当前玩家为cu ...
- c#取数据库数据 ---两种方法
通常有以下两种方式 SqlDataReader 和SqlDataAdapter|DataSet方式 SqlDataReader 方式使用方式如下: using System; using System ...
- JAVA实现Word(doc)文件读写
1.pom.xml依赖 <dependencies> <dependency> <groupId>org.apache.poi</groupId> &l ...
- 【DWM1000】 code 解密5一ACHOR 第一次回家Main 函数
instance_run(); if((instance_data[0].monitor == 1) && ((portGetTickCnt() - instance_data[0]. ...
- C++学习笔记56:异常处理
异常处理 异常处理的语法 抛掷异常的程序段 throw表达式: 捕获并处理异常的程序段 try 复合语句 catch(异常声明) 复合语句 catch(异常声明) 复合语句 注意:如果匹配的处理器没有 ...
- 数据结构 Sunday算法
Sunday算法是Daniel M.Sunday于1990年提出的字符串模式匹配算法.相对比较KMP和BM算法而言,简单了许多. Sunday算法的思想类似于BM算法中的坏字符思想,有点像其删减版.差 ...
- hiredis 使用 linux c++
1.linux下如何安装hiredis 1)下载地址 https://github.com/redis/hiredis 2)编译和安装 解压后的文件夹执行 make;make install; 3) ...
- sql 2008 查询性能优化笔记
索引: set statistics io on select p.productID,p.name,p.Weight,p.StandardCost from production.product p ...