JSHelper时间格式化
Helper.prototype.FormatDate = function (format) {
var _now = new Date();
var o = {
"M+": _now.getMonth() + 1, //month
"d+": _now.getDate(), //day
"h+": _now.getHours(), //hour
"m+": _now.getMinutes(), //minute
"s+": _now.getSeconds(), //second
"q+": Math.floor((_now.getMonth() + 3) / 3), //quarter
"S": _now.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (_now.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;
}
JSHelper时间格式化的更多相关文章
- strftime 日期时间格式化
strftime() 函数根据区域设置格式化本地时间/日期,函数的功能将时间格式化,或者说格式化一个时间字符串. size_t strftime(char *strDest,size_t maxsiz ...
- javascript 时间格式化
添加扩展 //时间格式化扩展Date.prototype.format = function(format){ var o = { "M+" : this.getMonth()+1 ...
- js时间格式化
const formatDate = timestamp => { const date = new Date(timestamp); const m = date.getMonth() + 1 ...
- js对特殊字符转义、时间格式化、获取URL参数
/*特殊字符转义*/ function replace_html(str) { var str = str.toString().replace(/&/g, "&" ...
- 特殊字符转义&时间格式化&获取URL参数
/*特殊字符转义*/ function htmlspecialchars (str) { var str = str.toString().replace(/&/g, "&& ...
- 【AspNetCore】【WebApi】扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat)
扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat) 一.背景 大家在使用WebApi时,会用到DateTime为参数,类似于这 ...
- EasyUI Datagrid Datetime(EasyUI DataGrid 时间格式化)
EasyUI DataGrid 时间格式化 方法一: var Common = { //EasyUI用DataGrid用日期格式化 TimeFormatter: function (value, re ...
- js Date 时间格式化的扩展
js Date 时间格式化的扩展: Date.prototype.format = function (fmt) { var o = { , //月 "d+": this.getD ...
- SqlServer时间格式化
最近用的SqlServer比较多,时间格式化老是忘记,现整理如下:(来源于网上,具体来源地址忘记了,归根到底MSDN吧) SELECT CONVERT(varchar(50), GETDATE(), ...
随机推荐
- Keil软件常见的警告和错误含义。——Arvin
1. warning: #767-D: conversion from pointer to smaller integer 解释:将指针转换为较小的整数 影响:可能造成的影响:容易引起数据截断,造 ...
- GNS3 IOU 配置
GNS3使用视频: http://edu.51cto.com/lesson/id-25295.html GNS3 IOU 与VM http://www.mamicode.com/info-detail ...
- Unity3d调用iOS陀螺仪
How to write gyroscope controller with Unity3d http://blog.heyworks.com/how-to-write-gyroscope-contr ...
- yum源安装Mysql
Mysql版本:5.7 进入mysql官网,复制下载链接 步骤: (1) wget http://dev.mysql.com/get/mysql57-community-release-el6-9. ...
- 关于css
已经学了四天的css.现在对于css的了解还很肤浅,首先,我对基础的还不是很了解. 级联样式表(Cascading Style Sheet)简称“CSS”,通常又称为“风格样式表(Style Shee ...
- java Resource
ClassPathResource: String resource = ""; //相对路径 Resource resource = new ClassPathResource( ...
- F2工作流引擎参与者类型成员的交、并、互拆计算规则
计算描述:计算规则指的是和其它“参与者类型成员”的之间的计算,必须求解处理人不为空的情况下才进行规则计算,各个“参与者类型成员”按序号顺序执行. 计算算法:并集(权重最低),交集(权重中) ...
- http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html(转载)(原作者:AstralWind)
Python正则表达式指南 本文介绍了Python对于正则表达式的支持,包括正则表达式基础以及Python正则表达式标准库的完整介绍及使用示例.本文的内容不包括如何编写高效的正则表达式.如何优 ...
- PDF 补丁丁 0.5.0.2691 发布(替换字库新增字符映射功能)
新版本在替换 PDF 字体功能中增加了替换字符的功能. 某些 PDF 文档可能由于编码错误的问题,复制出来的文本是乱码. 对于这种文档,可以使用此功能将错误的编码映射到正确的字符上,从而实现修复文档的 ...
- navicat 创建的表,username字段不能接受中文名字。
用navicat 创建的表,username(varchar)字段不能接受中文名字. 解决方法如下: 选中所创建的users表,打开“设计表”,选中username字段,看到下面是字符集latin1, ...