js 时间日期格式转换
Date.prototype.Format = function(formatStr) {
var str = formatStr;
var Week = ['日', '一', '二', '三', '四', '五', '六'];
str = str.replace(/yyyy|YYYY/, this.getFullYear());
str = str.replace(/yy|YY/, (this.getYear() % 100) > 9 ? (this.getYear() % 100).toString() : '0' + (this.getYear() % 100));
str = str.replace(/MM/, (this.getMonth() + 1) > 9 ? (this.getMonth() + 1).toString() : '0' + (this.getMonth() + 1));
str = str.replace(/M/g, (this.getMonth() + 1));
str = str.replace(/w|W/g, Week[this.getDay()]);
str = str.replace(/dd|DD/, this.getDate() > 9 ? this.getDate().toString() : '0' + this.getDate());
str = str.replace(/d|D/g, this.getDate());
str = str.replace(/hh|HH/, this.getHours() > 9 ? this.getHours().toString() : '0' + this.getHours());
str = str.replace(/h|H/g, this.getHours());
str = str.replace(/mm/, this.getMinutes() > 9 ? this.getMinutes().toString() : '0' + this.getMinutes());
str = str.replace(/m/g, this.getMinutes());
str = str.replace(/ss/, this.getSeconds() > 9 ? this.getSeconds().toString() : '0' + this.getSeconds());
str = str.replace(/s/g, this.getSeconds());
str = str.replace(/S/,this.getMilliseconds());
return str
}
console.log(new Date().Format("yy-M-d h:m:s:S w"));
js 时间日期格式转换的更多相关文章
- JS时间日期格式转换
第一种: function ConvertJSONDate(jsondate) { if (jsondate != "" && jsondate ...
- Java练习 SDUT-2246_时间日期格式转换
时间日期格式转换 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 对于日期的常用格式,在中国常采用格式的是"年 ...
- [js] js和C# 时间日期格式转换
下午在搞MVC和EXTJS的日期格式互相转换遇到了问题,我们从.NET服务器端序列化一个DateTime对象的结果是一个字符串格式,如 '/Date(1335258540000)/' 这样的字串. 整 ...
- js和C# 时间日期格式转换
下午在搞MVC和EXTJS的日期格式互相转换遇到了问题,我们从.NET服务器端序列化一个DateTime对象的结果是一个字符串格式,如 '/Date(1335258540000)/' 这样的字串. 整 ...
- Java时间日期格式转换 转自:http://www.cnblogs.com/edwardlauxh/archive/2010/03/21/1918615.html
Java时间格式转换大全 import java.text.*; import java.util.Calendar; public class VeDate { /** * 获取现在时间 * * @ ...
- js json日期格式转换日期方法
接收json数据,日期格式为:"\/Date(1414078309687)\/" var value = "/Date(1414078309687)/"; ...
- JS关于日期格式转换的问题
写Js时,有个地方用到日期,要求是yyyy--MM--dd的格式,于是想到了format函数,下面介绍了时间函数的定义,和调用前引入函数和如何格式化自己想要的日期格式. //当前时间 var Time ...
- poj 3751 时间日期格式转换
题目链接:http://poj.org/problem?id=3751 题目大意:按照要求的格式将输入的时间日期进行转化. #include <iostream> #include < ...
- Java时间日期格式转换
1.这个是系统自动默认的时间格式,或者说是美式格式: Long time = System.currentTimeMillis(); Date date = new Da ...
随机推荐
- AngularJS基于模块化的MVC实现
AngularJS基于模块化的MVC实现 <!DOCTYPE html> <html> <head> <meta charset="UTF-8&qu ...
- 校园电商项目(1) 基于SSM
第一步:搭好环境 我这里使用Eclipse做本次的项目,tomcat.maven啥的怎么弄就跳过了ヾ(o・ω・)ノ 第二步:创建工程 我们首先创建一个maven项目,选择最后一个,创建完之后发现报错, ...
- Spring boot + mybatis + orcale实战(干货)
废话少说,直接上步骤: 第一步:安装好IDEA(此处省略) 第二步:在IDEA新建springboot工程 第三步:在springboot工程的pom.xml添加oracle和mybait依赖 < ...
- idea 创建的spingmvc 引入jquery后jquery函数始终不执行的原因
- Python深入类和对象
一. 鸭子类型和多态 1.什么是鸭子类型: 在程序设计中,鸭子类型(英语:Duck typing)是动态类型和某些静态语言的一种对象推断风格."鸭子类型"像多态一样工作,但是没有继 ...
- case when 空值判断
在对数据库进行查询时,遇到了一个问题:查询结果中的某一列需要判断另一列是否为空的来确定值,自然就想到了case when,于是写出了下面的SQL(其他部分省略): (case date when nu ...
- 为WebRTC 应用部署Turn Server
部署WebRTC 或 SIP p2p 方案时经常会遇到p2p 无法穿透的环境, 这时就是TunServer 的用武之地了. 这里我们使用turnserver-0.7.3 下载confuse依赖库 wg ...
- How to install Windows 7 SP1 on Skylake
Download gigabyte windows usb installation tool http://www.gigabyte.cn/WebPage/-79/usb.html get Wind ...
- cuda编程-并行规约
利用shared memory计算,并避免bank conflict:通过每个block内部规约,然后再把所有block的计算结果在CPU端累加 代码: #include <cuda_runti ...
- How the Microsoft Bot Framework Changed Where My Friends and I Eat: Part 1
Bots are everywhere nowadays, and we interact with them all of the time. From interactions on our ph ...