jquery格式化时间
使用方法:
new Date().format("yyyy-MM-dd hh:mm:ss");
格式:
Date.prototype.format = function (format) {
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(format)) {
format = format.replace(RegExp.$1, (this.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;
}
jquery格式化时间的更多相关文章
- Jquery 格式化时间
我们常常会通过datetime得到时间,但是网页前台往往会显示不同的时间 如:2013-12-15 2013年12月23日 2013 12 15 等多种显示效果,这就需要我们把时间格式化一下. 下面是 ...
- jQuery格式化时间插件formatDate
一.不传时间 $.formatDate("yyyy-MM-dd HH:mm:ss"); 二.传时间 $.formatDate("yyyy-MM-dd HH:mm:ss ...
- 【原创】关于jquery实现格式化时间
//js格式化时间,参数jsonDate可以是后台数据 function jsonDateFormat(jsonDate) { try { var date = new Date(parseInt(j ...
- WP7、WP8 格式化时间为距当前多少时间
方法一: 使用 toolkit的 RelativeTimeConverter,使用方式 <phone:PhoneApplicationPage.Resources> <toolkit ...
- 模仿win10样式,基于jquery的时间控件
工作需要,写了一个基于jquery的时间控件,仿win10系统时间控件格式. 目前基本功能都有了,但时间格式只实现少数,但由于结构设计已经充分优化,填充起来非常容易. 这个控件相对网上其他的时间控件, ...
- golang 格式化时间为字符串
package main import ( "fmt" "reflect" "time" ) func main() { //格式化字符串为 ...
- php友好格式化时间
php格式化时间显示 function toTime($time) {//$time必须为时间戳 $rtime = date("Y-m-d H:i",$time); $htime ...
- java 格式化时间
java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); form ...
- 封装insertAfter、addClass、格式化时间
insertAfter,在JS节点操作中,并没有insertAfter方法,因此需要重新封装 function insertAfter(newEle,targetNode) { var oParent ...
随机推荐
- HighCharts日期及数值格式化
1.函数原型 1 dateFormat(Stringformat,[Numbertime],[Booleancapitalize])::String 2.说明 格式化JavaScript 时间(也 ...
- oracle 中的trunc()函数及加一个月,一天,一小时,一分钟,一秒钟方法
返回处理后的数据,不同于round()(对数值进行四舍五入处理),该函数不对指定小数前或后的数值部分进行舍入处理. 语法:trunc(number[,decimals]) 其中,number为待做处理 ...
- golang笔记——命令
1.GO命令一览 GO提供了很多命令,包括打包.格式化代码.文档生成.下载第三方包等等诸多功能,我们可以通过在控制台下执行 go 来查看内置的所有命令 下面来逐个介绍,也可以详细参考 https:// ...
- [转载]SVN如何恢复已删除文件或文件夹
http://blog.sina.com.cn/s/blog_694d806e0100kaqz.html 用TortoiseSVN: 1.在本地working copy中,用TortoiseSVN-& ...
- 电脑开机黑屏,显示Reboot and Select proper boot device!
“reboot and select proper boot device or insert boot media in selected boot device and press a key” ...
- javacomm64位用不了,可以使用RXTXcomm for x64
安装完后把导入包名改一下就行了! 附上读串口代码: /* * @(#)SimpleRead.java 1.12 98/06/25 SMI * * Copyright (c) 1998 Sun Micr ...
- ytkah网站建设解决方案 大中小微企业营销利器
为大中小微企业提供网站设计制作优化服务,PC移动微网站三合一,抢占市场先机.读万卷书不如走万里路,走万里路不如阅人无数.说再多空洞无物不如上案例几簇 优秀案例展示,上市公司人人网旗下游戏<天书奇 ...
- Linux 修改主机名 和 ip 映射关系
1. 修改主机名 vim /etc/sysconfig/network NETWORKING=yes HOSTNAME=hadoop 2. 修改主机名和IP的映射关系 vim /etc/hosts 1 ...
- 【Go入门教程8】总结(25个关键字)
这一章我们主要介绍了Go语言的一些语法,通过语法我们可以发现Go是多么的简单,只有二十五个关键字.让我们再来回顾一下这些关键字都是用来干什么的. break default func ...
- C 语言sscanf
C语言以sscanf逗号作为分割符 ]={}; ]={}; ]={}; sscanf(],&buf_b[],&buf_b[]); printf("************** ...