最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js將long日期格式轉(zhuǎn)換為標(biāo)準(zhǔn)日期格式實(shí)現(xiàn)思路

 更新時(shí)間:2013年04月07日 17:09:15   作者:  
本文為大家詳細(xì)介紹下js將long日期格式轉(zhuǎn)換為標(biāo)準(zhǔn)日期格式,感興趣的朋友可以參考下哈,希望可以幫助到你
js將long日期格式轉(zhuǎn)換為標(biāo)準(zhǔn)日期格式
復(fù)制代碼 代碼如下:

<script language="javascript">
//擴(kuò)展Date的format方法
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;
}
/**
*轉(zhuǎn)換日期對(duì)象為日期字符串
* @param date 日期對(duì)象
* @param isFull 是否為完整的日期數(shù)據(jù),
* 為true時(shí), 格式如"2000-03-05 01:05:04"
* 為false時(shí), 格式如 "2000-03-05"
* @return 符合要求的日期字符串
*/
function getSmpFormatDate(date, isFull) {
var pattern = "";
if (isFull == true || isFull == undefined) {
pattern = "yyyy-MM-dd hh:mm:ss";
} else {
pattern = "yyyy-MM-dd";
}
return getFormatDate(date, pattern);
}
/**
*轉(zhuǎn)換當(dāng)前日期對(duì)象為日期字符串
* @param date 日期對(duì)象
* @param isFull 是否為完整的日期數(shù)據(jù),
* 為true時(shí), 格式如"2000-03-05 01:05:04"
* 為false時(shí), 格式如 "2000-03-05"
* @return 符合要求的日期字符串
*/
function getSmpFormatNowDate(isFull) {
return getSmpFormatDate(new Date(), isFull);
}
/**
*轉(zhuǎn)換long值為日期字符串
* @param l long值
* @param isFull 是否為完整的日期數(shù)據(jù),
* 為true時(shí), 格式如"2000-03-05 01:05:04"
* 為false時(shí), 格式如 "2000-03-05"
* @return 符合要求的日期字符串
*/
function getSmpFormatDateByLong(l, isFull) {
return getSmpFormatDate(new Date(l), isFull);
}
/**
*轉(zhuǎn)換long值為日期字符串
* @param l long值
* @param pattern 格式字符串,例如:yyyy-MM-dd hh:mm:ss
* @return 符合要求的日期字符串
*/
function getFormatDateByLong(l, pattern) {
return getFormatDate(new Date(l), pattern);
}
/**
*轉(zhuǎn)換日期對(duì)象為日期字符串
* @param l long值
* @param pattern 格式字符串,例如:yyyy-MM-dd hh:mm:ss
* @return 符合要求的日期字符串
*/
function getFormatDate(date, pattern) {
if (date == undefined) {
date = new Date();
}
if (pattern == undefined) {
pattern = "yyyy-MM-dd hh:mm:ss";
}
return date.format(pattern);
}
//alert(getSmpFormatDate(new Date(1279849429000), true));
//alert(getSmpFormatDate(new Date(1279849429000),false));
//alert(getSmpFormatDateByLong(1279829423000, true));
alert(getSmpFormatDateByLong(1279829423000,false));
//alert(getFormatDateByLong(1279829423000, "yyyy-MM"));
//alert(getFormatDate(new Date(1279829423000), "yy-MM"));
//alert(getFormatDateByLong(1279849429000, "yyyy-MM hh:mm"));
</script>

相關(guān)文章

最新評(píng)論

理塘县| 陆丰市| 二连浩特市| 松潘县| 汉川市| 三亚市| 阿图什市| 苍溪县| 连城县| 精河县| 镇雄县| 新安县| 万宁市| 潜江市| 柏乡县| 万载县| 稻城县| 阳曲县| 屯留县| 泰顺县| 卫辉市| 新泰市| 吉林市| 乐安县| 冀州市| 桂阳县| 洪雅县| 东丰县| 德钦县| 葵青区| 开封县| 克东县| 水富县| 沙田区| 富锦市| 繁昌县| 合阳县| 榆中县| 新田县| 尖扎县| 大田县|