首页 > 其他分享 >js获取北京时间代码

js获取北京时间代码

时间:2024-08-09 09:28:23浏览次数:13  
标签:xmlhttp 代码 js 获取 second dateStr date var month

var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");
xmlhttp.open("GET", "https://www.bjsj5.com", false);
xmlhttp.setRequestHeader("If-Modified-Since", "bjtime");
xmlhttp.send();
var dateStr = xmlhttp.getResponseHeader("Date");
var date = new Date(dateStr);
var year = date.getFullYear();
var month = date.getMonth() + 1;
var date1 = date.getDate();
var hour = date.getHours();
var minutes = date.getMinutes();
var second = date.getSeconds();
alert(date + "  |  " + year + "年" + month + "月" + date1 + "日" + hour + "时" + minutes + "分" + second + "秒");

标签:xmlhttp,代码,js,获取,second,dateStr,date,var,month
From: https://www.cnblogs.com/sbcx12333/p/18350151

相关文章