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

js中?new?Date().getTime()得到的是毫秒數(shù)時(shí)間戳

 更新時(shí)間:2023年07月02日 10:56:39   作者:萬筱武  
今天在寫一個(gè)函數(shù)的時(shí)候需要用的一個(gè)時(shí)間戳方便調(diào)用不同的隨機(jī)數(shù)?那么時(shí)間戳就是比較好的方式,主要怕瀏覽器緩存數(shù)據(jù),下面就為大家簡(jiǎn)單介紹一下

應(yīng)用實(shí)例

var filename = '/demoad.css?' + new Date().getTime();

js中 var time = new Date().getTime()得到的是毫秒數(shù)

1、時(shí)間戳轉(zhuǎn)日期字符串

function getLocalTime(nS) {     
		var d = new Date(parseInt(nS)* 1000);    //根據(jù)時(shí)間戳生成的時(shí)間對(duì)象
		var date = (d.getFullYear()) + "-" + 
					(d.getMonth() + 1) + "-" +
					(d.getDate()) + " " + 
					(d.getHours()) + ":" + 
					(d.getMinutes()) + ":" + 
					(d.getSeconds()); 
		return date;   
}
document.write(getLocalTime(1552889937));

2、當(dāng)前時(shí)間換時(shí)間戳

var timestamp = parseInt(new Date().getTime()/1000);    // 當(dāng)前時(shí)間戳
document.write(timestamp);

3、當(dāng)前時(shí)間換日期字符串

var now = new Date();
var yy = now.getFullYear();      //年
var mm = now.getMonth() + 1;     //月
var dd = now.getDate();          //日
var hh = now.getHours();         //時(shí)
var ii = now.getMinutes();       //分
var ss = now.getSeconds();       //秒
var clock = yy + "-";
if(mm < 10) clock += "0";
clock += mm + "-";
if(dd < 10) clock += "0";
clock += dd + " ";
if(hh < 10) clock += "0";
clock += hh + ":";
if (ii < 10) clock += '0'; 
clock += ii + ":";
if (ss < 10) clock += '0'; 
clock += ss;
document.write(clock);     //獲取當(dāng)前日期

4、日期字符串轉(zhuǎn)時(shí)間戳

var date = '2015-03-05 17:59:00.0';
date = date.substring(0,19);    
date = date.replace(/-/g,'/'); 
var timestamp = new Date(date).getTime();
document.write(timestamp);

5、時(shí)間戳轉(zhuǎn)日期字符串

var timestamp = '1425553097';
var d = new Date(timestamp * 1000);    //根據(jù)時(shí)間戳生成的時(shí)間對(duì)象
var date = (d.getFullYear()) + "-" + 
           (d.getMonth() + 1) + "-" +
           (d.getDate()) + " " + 
           (d.getHours()) + ":" + 
           (d.getMinutes()) + ":" + 
           (d.getSeconds());
document.write(date);

更多的關(guān)于時(shí)間戳的可以參考這篇文章 http://m.fzitv.net/article/278265.htm

到此這篇關(guān)于js中 new Date().getTime()得到的是毫秒數(shù)時(shí)間戳的文章就介紹到這了,更多相關(guān)js時(shí)間戳內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

曲阳县| 固原市| 石柱| 新津县| 隆德县| 柏乡县| 筠连县| 吉安市| 修武县| 伊金霍洛旗| 瑞安市| 太原市| 贺兰县| 都匀市| 莎车县| 云林县| 达尔| 定远县| 潞西市| 哈尔滨市| 东宁县| 青阳县| 定西市| 临沂市| 华安县| 霍州市| 恩施市| 紫云| 大悟县| 勃利县| 漳浦县| 小金县| 竹北市| 昌都县| 镇赉县| 独山县| 筠连县| 金华市| 凭祥市| 双流县| 祥云县|