js时间格式化(yy年MM月dd日 hh:mm)
//时间格式化
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
} 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;
} function formatData(str, regexp) {
// 转换日期格式
str = str.replace(/-/g, '/'); // "2010/08/01";
// 创建日期对象
var date = new Date(str);
return date.format(regexp);
} formatData(data[i].create_time, 'yy年MM月dd日 hh:mm')
js时间格式化(yy年MM月dd日 hh:mm)的更多相关文章
- vue-cli 利用moment.js转化时间格式为YYYY年MM月DD日,或者是YYYY-MM-DD HH:MM:SS 等格式
1.在mian.js引入moment import moment from 'moment' Vue.prototype.$moment = 'moment' 2. 在main.js 设置全局过滤器 ...
- 在rdlc 中 显示成 yyyy年MM月dd日
在rdlc 中 显示成 yyyy年MM月dd日, 采用: =First(Format(Fields!添加时间.Value,"yyyy年MM月dd日") )
- java 和js 时间 格式化(yyyy-MM-dd HH:mm:ss) 以及获取当前时间
1.js var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970 ...
- js 时间格式化 (兼容safari)
js 时间格式化,兼容IE8和safari浏览器. function formatDate(date, fmt, near, type) { var dateStr = date; if (!date ...
- js时间格式化函数(兼容IOS)
* 时间格式化 * @param {Object} dateObj 时间对象 * @param {String} fmt 格式化字符串 */ dateFormat(dateObj, fmt) { le ...
- 时间戳显示为多少分钟前,多少天前的JS处理,JS时间格式化,时间戳的转换
var dateDiff = function (timestamp) { // 补全为13位 var arrTimestamp = (timestamp + '').split(''); for ( ...
- js时间格式化函数,支持Unix时间戳
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- 表单序列化json字符串和js时间格式化
js时间格式化 new Date().format("时间格式") Date.prototype.format = function(fmt) { var o = { ...
- java为啥计算时间从1970年1月1日开始
http://www.myexception.cn/program/1494616.html ————————————————————————————————————————————————————— ...
随机推荐
- 【Alpha版本】冲刺-Day4
队伍:606notconnected 会议时间:11月12日 会议总结 张斯巍(433) 今天安排:图片查看界面设计 完成度:40% 明天计划:设置界面设计 遇到的问题:校运会比赛时间不够 感想:因为 ...
- Docker distrubution in django
https://www.syncano.io/blog/configuring-running-django-celery-docker-containers-pt-1/ Update: Fig ha ...
- Opencv中将CvMat转为IplImage
Opencv中将CvMat转为IplImage,并在内存获得起头指针,而不用cvSaveImage(),贴上代码 IplImage * imgg = NULL; imgg = cvCreateImag ...
- JQuery遍历方法$.each输出函数
each()方法能使DOM循环结构简洁,不容易出错.each()函数封装了十分强大的遍历功能,使用也很方便,它可以遍历一维数组.多维数组.DOM, JSON 等等在javaScript开发过程中使用$ ...
- Linux的95个小技巧
Linux的95个小技巧 by WEB全栈工程师 on 2012 年 03 月 27 日 这里总结了Linux使用中的一些小技巧 1.实现RedHat非正常关机的自动磁盘修复 先登录到服务器,然后在/ ...
- String类中的一些函数使用方法
最常用的就是Length()函数了,求字符串的长度 String s="";int i=s.length();i结果为0. 如果是String s=null;int i=s.len ...
- Java国际化程序
根据不同的国家配置不同的资源文件(资源文件有时也称为属性文件,后缀为.properties),所有的资源文件以键值对的形式出现. Locale类 ResourceBundle类 //========= ...
- 端口扫描(TCP)
还待优化... #include <string.h> #include <WinSock.h> #include <stdio.h> #pragma commen ...
- ecshop商品-》获取促销商品
lib_goods.php->function get_promote_goods(){} /** * 获得促销商品 * * @access public * @return array */ ...
- swiper超出部分出现滚动条
html代码 <div class="wrap swiper-container"> <div class="swiper-wrapper"& ...