1. まとめトップ
0 お気に入り 9935 view
お気に入り追加

時間取得タグ

<script type="text/javascript">
<!--
var bolTimer1 = false;
var bolTimer2 = false;
var bolTimer3 = false;
function dejitaruTokei(){
document.writeln("<table border=0 cellspacing=0><tr>");
document.write(defWatchTD("00","black","idFYR"));
document.write(defWatchTD("/","black"));
document.write(defWatchTD("00","black","idMN"));
document.write(defWatchTD("/","black"));
document.write(defWatchTD("00","black","idDT"));
document.write(defWatchTD("(","black"));
document.write(defWatchTD("00","black","idDYJ"));
document.write(defWatchTD(") ","black"));
document.write(defWatchTD("00","black","idHH"));
document.write(defWatchTD(":","black"));
document.write(defWatchTD("00","black","idNN"));
document.write(defWatchTD(":","black"));
document.write(defWatchTD("00","black","idSS"));
document.write("</tr></table>");
setTime();
}
function defWatchTD(str, iro, divID){
return "<td><b><div id='" + divID + "'>" + str + "</div></b></td>";
}
function Days()
{
this[0] = "日"; this[1] = "月"; this[2] = "火"; this[3] = "水";
this[4] = "木"; this[5] = "金"; this[6] = "土";
}
function setTime(){
var now = new Date();
var yr = now.getYear();
var mn = now.getMonth() + 1;
var dt = now.getDate();
var dy = now.getDay();
var hh = now.getHours();
var nn = now.getMinutes();
var ss = now.getSeconds();
var fyr = (yr < 1900) ? 1900 + yr : yr;
var dys = new Days();
var dyj = dys[dy];
if(mn<10) mn="0"+mn;
if(dt<10) dt="0"+dt;
if(hh<10) hh="0"+hh;
if(nn<10) nn="0"+nn;
if(ss<10) ss="0"+ss;
document.getElementById("idFYR").innerHTML=fyr;
document.getElementById("idMN").innerHTML=mn;
document.getElementById("idDT").innerHTML=dt;
document.getElementById("idDYJ").innerHTML=dyj;
document.getElementById("idHH").innerHTML=hh;
document.getElementById("idNN").innerHTML=nn;
document.getElementById("idSS").innerHTML=ss;
setTimeout("setTime()",1000);
}
//-->
</script>

時間表示タグ

<script type="text/javascript">
<!--
dejitaruTokei();
//-->
</script>

表示例

2000/01/01(土) 00:00:00

このように表示されリアルタイムに時刻をきざみます

変更方法

document.write(defWatchTD("★","black"));

★の部分を書き換える事で区切り部分を変更できます

一括

<script type="text/javascript">
<!--
var bolTimer1 = false;
var bolTimer2 = false;
var bolTimer3 = false;
function dejitaruTokei(){
document.writeln("<table border=0 cellspacing=0><tr>");
document.write(defWatchTD("00","black","idFYR"));
document.write(defWatchTD("/","black"));
document.write(defWatchTD("00","black","idMN"));
document.write(defWatchTD("/","black"));
document.write(defWatchTD("00","black","idDT"));
document.write(defWatchTD("(","black"));
document.write(defWatchTD("00","black","idDYJ"));
document.write(defWatchTD(") ","black"));
document.write(defWatchTD("00","black","idHH"));
document.write(defWatchTD(":","black"));
document.write(defWatchTD("00","black","idNN"));
document.write(defWatchTD(":","black"));
document.write(defWatchTD("00","black","idSS"));
document.write("</tr></table>");
setTime();
}
function defWatchTD(str, iro, divID){
return "<td><b><div id='" + divID + "'>" + str + "</div></b></td>";
}
function Days()
{
this[0] = "日"; this[1] = "月"; this[2] = "火"; this[3] = "水";
this[4] = "木"; this[5] = "金"; this[6] = "土";
}
function setTime(){
var now = new Date();
var yr = now.getYear();
var mn = now.getMonth() + 1;
var dt = now.getDate();
var dy = now.getDay();
var hh = now.getHours();
var nn = now.getMinutes();
var ss = now.getSeconds();
var fyr = (yr < 1900) ? 1900 + yr : yr;
var dys = new Days();
var dyj = dys[dy];
if(mn<10) mn="0"+mn;
if(dt<10) dt="0"+dt;
if(hh<10) hh="0"+hh;
if(nn<10) nn="0"+nn;
if(ss<10) ss="0"+ss;
document.getElementById("idFYR").innerHTML=fyr;
document.getElementById("idMN").innerHTML=mn;
document.getElementById("idDT").innerHTML=dt;
document.getElementById("idDYJ").innerHTML=dyj;
document.getElementById("idHH").innerHTML=hh;
document.getElementById("idNN").innerHTML=nn;
document.getElementById("idSS").innerHTML=ss;
setTimeout("setTime()",1000);
}
dejitaruTokei();
//-->
</script>

1







  • 話題の動画をまとめよう