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(), ...
随机推荐
- Makefile相关知识
1. Makefile的编写: 1>. makefile的命名 1. makefile 2. Makefile 2>. makefile中的规则 三部分: 目标(app):依赖(main. ...
- hibernate 和 myBatis 比较
Hibernate与 MyBatis的比较 第一章 Hibernate与MyBatis Hibernate 是当前最流行的O/R mapping框架,它出身于sf.net,现在已经成为Jbos ...
- 报错记录:getOutputStream() has already been called for this response
仅作记录:参考文章:http://www.blogjava.net/vickzhu/archive/2008/11/03/238337.html 报错信息: java.lang.IllegalStat ...
- RStudio相关
1.设置默认目录,tool-Global Options,设定后要重启RStudio才能生效2.Ctrl+l清屏控制台3.↑健.回忆前一条命令,↓健相反4.Ctrl+↑,查找相应前缀的历史记录5.创建 ...
- js制作简单的计算器
学着做了一个简单的计算器!记录记录!哈哈 <!DOCTYPE html> <html> <head> <title>简单的计算器</title&g ...
- eclipse svn提交报错
修改文件格式:右键-properties-text file encoding-other UTF-8
- 大家把做的公祭日的ps上传哦
上传时图片保存为JPG,写上自己的学号,说说自己的创作构思
- 简单的例子 关于Java内存管理的讲解
我想做的是,逐行读取文件,然后用该行的电影名去获取电影信息.因为源文件较大,readlines()不能完全读取所有电影名,所以我们逐行读取. 就这段代码,我想要在位置二处使用base64,然后结果呢? ...
- 许愿墙的搭建(基于Apache+php+mysql)
一.准备部分:CentOS 7 , Linux 文本 各自配置好环境 二. CentOS 7准备如下: yum install httpd -y #安装httpd yum install php ...
- 前端面试题2016--CSS
介绍一下标准的CSS的盒子模型?低版本IE的盒子模型有什么不同的? (1)有两种,IE 盒子模型.W3C 盒子模型:(2)盒模型:内容(content).填充(padding).边界(margin). ...