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(), ...
随机推荐
- return 关键字的作用
注意: 如果一个函数的返回值类型是具体的数据类型,那么该函数就必须要保证在任意情况下都保证有返回值.(除了返回值类型是void以外) return 关键字的作用: 1. 返回数据给函数的调用者. 2. ...
- 18TH赛事管理
赛事管理者 项目psp: 一.计划 估计这个任务需要7天时间 二.开发 1.需求分析 作为一个赛事管理者,我希望知道每场比赛的队伍得分和积分情况,以便给每队进行排名. 2.生成设计文档 查询出每场得分 ...
- 转:Eclipse插件开发之TreeViewer
http://www.tuicool.com/articles/e6fmE3R contentprovider在插件开发和RCP(Rich Client Platform)开发中常常被用到,譬如你要创 ...
- CI 3.0.6 控制器打印base_url 地址不为 localhost的解决方法
1.在application\config\autoload.php 第92行 加载url $autoload['helper'] = array('url'); 2.application\c ...
- ArcGIS操作Excel文件没有注册类解决办法
在ArcGIS Desktop中进行表连接时选择了一张excel表,但添加该表时报错: 原因是机器上缺少Office的数据驱动. ArcGIS 支持 : Excel 2003 以及更早版本的 .xls ...
- 安卓xml文件中常见的问题
1.EditText显示不完全
- oracle Net Manager 服务命名无法配置(无法新建、添加服务名)
今天在配置oracle Net Manager 配置服务命名的时候总是无法配置,以前配置的服务名都显示不出来,然后点击绿色添加按钮也没反应,因为先前我修改了oracle\product\10.2.0\ ...
- 3level_menus
# encoding: utf-8 # Creator:耿亚月 Creation time:2017-1-2 # Modifier:耿亚月 Modification time:2017-1-2 #输入 ...
- ViewBag是如何实现的
ExpandoObject 在 MVC 3 的时候 Controller 可以通过 ViewBag 将数据传送到 View.如下就是通过 ViewBag 设置页面标题: public ActionRe ...
- WebView 的使用----android 网络连接处理分析
在Android中,可以有多种方式来实现网络编程: 创建URL,并使用URLConnection/HttpURLConnection 使用HttpClient 使用WebView 创建URL,并使用U ...