javascript日期转换 时间戳转日期格式的代码一例
javascript日期转换代码。
/** *时间戳 转换为 日期格式 *site http://www.jbxue.com *date 2013-4-8 */ 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; } var testDate = new Date( 1320336000000 );//必须为整数型的毫秒数 var testStr = testDate.format("yyyy年MM月dd日hh小时mm分ss秒"); var testStr2 = testDate.format("yyyyMMdd hh:mm:ss"); alert(testStr + " " + testStr2);
>>> 您可能感兴趣的文章:
js 时间格式与时间戳转换的例子
js时间戳格式化成日期格式的几种方法
Javascript时间戳与php时间戳转换时要注意什么
您可能感兴趣的文章:
Javascript时间戳与php时间戳转换时要注意什么
javascript日期转换 时间戳转日期格式的代码一例
php日期函数的简单示例代码
php日期加减法运算小例子
php与Mysql日期时间(UNIX时间戳、格式化日期)转换的方法
php 创建以unix时间戳命名的文件夹
js时间戳格式化成日期格式方法汇总
php strtotime函数怎么用
php 时间戳函数总结与示例
php 获取今日、昨日、上周、本月的起始与结束时间戳