js格式化日期 年月日
/**
* 格式化日期
* @param value
* @param row
* @param index
* @returns
*/
function valueFormatterDate(value,row,index){
var time = new Date();
if(value){
if((value+"").indexOf("-")>0){
value=/\d{4}-\d{1,2}-\d{1,2}/g.exec(value);
return value;
}
time = new Date(value);
}
var year=time.getFullYear();
var month = time.getMonth() + 1;
var day = time.getDate();
if(month<10){
month="0"+month;
}
if(day<10){
day="0"+day;
}
return year+"-"+month+"-"+day;
}
js格式化日期 年月日的更多相关文章
- js格式化日期,获取当月的第一天,与最后一天.
//格式化日期 function setDate(date){ y=date.getFullYear(); m=date.getMonth()+1; d=date.getDate(); ...
- js格式化日期
/** *对日期进行格式化, * @param date 要格式化的日期 * @param format 进行格式化的模式字符串 * 支持的模式字母有: * y:年, * M:年中的月份(1-12), ...
- js格式化日期yyyyMMdd
先来一个土方法: <script>function getyyyyMMdd(){ var d = new Date(); var curr_date = d.getDate(); var ...
- js格式化日期工具类
就是一个工具类 开箱即用 传进一个指定的参数,格式化 //将时间戳格式化 function getMyDate(time){ if(typeof(time)=="undefined&quo ...
- JS 格式化日期
function formatDate(date){ var year=date.getFullYear(); var month=date.getMonth()+1; var date=date.g ...
- JS格式化日期时间的方法
//格式化时间的方法 function format(fmt, date) { var o = { "M+": date.getMonth() + 1, //月份 "d+ ...
- js 格式化日期 ("/Date(1400046388387)/")
var date = new Date(parseInt(str.replace(/\/Date\((-?\d+)\)\//, '$1'))); var d= date.getFullYear() + ...
- JS 格式化日期时间
方法一: // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1 ...
- js格式化日期时间
// 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).周(E).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1 ...
随机推荐
- uiwebview 兼容性 - IOS8及以上 WKWebView
@import WKWebView; WKWebView *webView = [[WKWebView alloc]init......]; 使用. WKWebView兼容 IOS 及 OSX.IOS ...
- mongodb的连接和开启安全验证
首先是启动mongodb a.打开cmd,cd进入mongodb的安装目录下的bin目录下面,执行 mongod --dbpath D:\MongoDBdata(数据存放的目录) 或者将mongodb ...
- Custom IFormatProvider
The following example shows how to write a custom IFormatProvider which you can use in methodString. ...
- C++Primer 第十五章
//1.面向对象程序设计的核心思想是数据抽象,继承,动态绑定. // 通过使用数据抽象,我们可以将类的接口和实现分离 // 使用继承,可以定义相似的类型并对其相似关系建模 // 使用动态绑定,可以在一 ...
- html 鼠标移入标签 显示小手指
<div style="width: 200px; height: 200px; background: red; cursor: pointer;"></div ...
- SQL order 排序
select * from emp;
- MFC架构
MFC的六大关键技术: 1)MFC程序的初始化过程 2)消息映射 3)运行时类型识别(RTTI) 4)动态创建 5)永久保存 6)消息传递 一.MFC的初始化过程: MFC的架构组成: 1.要有CWi ...
- hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4706 Children's Day Time Limit: 2000/1000 MS (Java/Others) ...
- .NET: 防止多个应用程序同时开
用到了Mutex这个类,直接看代码~ using System; using System.Collections.Generic; using System.Linq; using System.W ...
- C++之路进阶——codevs3287(货车运输)
3287 货车运输 2013年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description A 国有 n ...