JS获取当前时间.txt如果你看到面前的阴影,别怕,那是因为你的背后有阳光!我允许你走进我的世界,但绝不允许你在我的世界里走来走去。<SCRIPT LANGUAGE="JavaScript">
var myDate = new Date();
FullYear(); //获取完整的年份(4位,1970-????)
var LocaleTimeString(); //获取当前时间
if (mytime<"23:30:00"){
alert(mytime);
}
</SCRIPT>
2.<% //日期转换
java.util.Date currentTime = new java.util.Date();//得到当前系统时间
String str_date1 = formatter.format(currentTime); //将日期时间格式化
String str_date2 = String(); //将Date型日期时间转换成字符串形式
%>
1. 2008年11月13日 星期四 上午 10:13:46
<div id="Clock" align="center" ></div>
<script>
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today, theday;
today = new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
" 星期日",
" 星期一",
" 星期二",
" 星期三",
" 星期四",
" 星期五",
" 星期六");
theday = Year()+"年" + [Month()+1]+"月" +Date()+"日" + Day()+1];
intHours = Hours();
intMinutes = Minutes();
intSeconds = Seconds();
if (intHours == 0) {
hours = "12:";
xfile = " 午夜 ";
} else if (intHours < 12) {
hours = intHours+":";
xfile = " 上午 ";
} else if (intHours == 12) {
hours = "12:";
xfile = " 正午 ";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = " 下午 ";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = theday+xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
</script>
2. 2008年11月13 星期四
丙戌年 二月十五
<script language="JavaScript">
var bsYear;
var bsDate;
var bsWeek;
var arrLen=8; //数组长度
var sValue=0; //当年的秒数
var dayiy=0; //当年第几天
var miy=0; //月份的下标
var iyear=0; //年份标记
var dayim=0; //当月第几天
var spd=86400; //每天的秒数
var year1999="30;29;29;30;29;29;30;29;30;30;30;29"; //354
var year2000="30;30;29;29;30;29;29;30;29;30;30;29"; //354
var year2001="30;30;29;30;29;30;29;29;30;29;30;29;30"; //384
var year2002="30;30;29;30;29;30;29;29;30;29;30;29"; //354
var year2003="30;30;29;30;30;29;30;29;29;30;29;30"; //355
var year2004="29;30;29;30;30;29;30;29;30;29;30;29;30"; //384
var year2005="29;30;29;30;29;30;30;29;30;29;30;29"; //354
var year2006="30;29;30;29;30;30;29;29;30;30;29;29;30";
var month1999="正月;二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"
var month2001="正月;二月;三月;四月;闰四月;五月;六月;七月;八月;九月;十月;十一月;十二月"
var month2004="正月;二月;闰二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"
var month2006="正月;二月;三月;四月;五月;六月;七月;闰七月;八月;九月;十月;十一月;十二月"
var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";
var Ys=new Array(arrLen);
Ys[0]=919094400;Ys[1]=949680000;Ys[2]=980265600;
Ys[3]=1013443200;Ys[4]=1044028800;Ys[5]=1074700800;
Ys[6]=1107878400;Ys[7]=1138464000;
var Yn=new Array(arrLen); //农历年的名称
Yn[0]="己卯年";Yn[1]="庚辰年";Yn[2]="辛巳年";
Yn[3]="壬午年";Yn[4]="癸未年";Yn[5]="甲申年";
Yn[6]="乙酉年";Yn[7]="丙戌年";
var D=new Date();
var Year();
var Month()+1;
var Date();
var Day();
if (ww==0) ww="<font color=RED>星期日</font>";
if (ww==1) ww="星期一";
if (ww==2) ww="星期二";
if (ww==3) ww="星期三";
if (ww==4) ww="星期四";
if (ww==5) ww="星期五";
if (ww==6) ww="<font color=green>星期六</font>";
ww=ww;
var ss=Time() / 1000);
if (yy<100) yy="19"+yy;
for (i=0;i<arrLen;i++)
if (ss>=Ys[i]){
iyear=i;
sValue=ss-Ys[i]; //当年的秒数
}
dayiy=parseInt(sValue/spd)+1; //当年的天数
var dpm=year1999;
if (iyear==1) dpm=year2000;
if (iyear==2) dpm=year2001;
if (iyear==3) dpm=year2002;
if (iyear==4) dpm=year2003;
if (iyear==5) dpm=year2004;
if (iyear==6) dpm=year2005;
if (iyear==7) dpm=year2006;
dpm=dpm.split(";");
var Mn=month1999;
if (iyear==2) Mn=month2001;
if (iyear==5) Mn=month2004;
if (iyear==7) Mn=month2006;
Mn=Mn.split(";");
var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";
Dn=
Dn.split(";");
dayim=dayiy;
var total=new Array(13);
total[0]=parseInt(dpm[0]);
for (i=1;i<dpm.length-1;i++) total[i]=parseInt(dpm[i])+total[i-1];
for (i=dpm.length-1;i>0;i--)
if (dayim>total[i-1]){
dayim=dayim-total[i-1];
miy=i;
}
bsWeek=ww;
bsDate=yy+"年"+mm+"月";
bsDate2=dd;
bsYear="农历"+Yn[iyear];
bsYear2=Mn[miy]+Dn[dayim-1];
if (ss>=Ys[7]||ss<Ys[0]) bsYear=Yn[7];
function time(){
document.write("<table border=''0'' style=''font-size: 8pt; font-family:Tahoma'' cellspacing=''0'' width=''90'' bordercolor=''#cccccc'' height=''110'' cellpadding=''0''");
document.write("<tr><td align=''center'' style=''border: 1 solid #0099ff;padding-top:4px''><b><font color=#3366cc>"+bsDate+"</font><br><span style=''font-family: Arial Black;font-size:18pt;color:#FF0000''>"+bsDate2+"</span><br><br><span style=''FONT-SIZE: 10.5pt;color:#000000''>");
document.write(bsWeek+"</span><br>"+"<hr width=''60'' ></b><font color=#666666>");
document.write(bsYear+"<br>"+bsYear2+"</td></tr></table>");
}
</script>
<script>time()</script>
3. November 13,2008 10:15:58
<SCRIPT language=javascript>
<!--
function Year_Month(){
var now = new Date();
var yy = Year();
var mm = Month();
var mmm=new Array();
mmm[0]="January";
mmm[1]="February ";
mmm[2]="March";
mmm[3]="April";
mmm[4]="May";
mmm[5]="June";
mmm[6]="July";
mmm[7]="August";
mmm[8]="September";
mmm[9]="October";
mmm[10]="November";
mmm[11]="December";
mm=mmm[mm];
return(mm);
}
function thisYear(){
var now = new Date();
var yy = Year();
return(yy);
}
function Date_of_Today(){
var now = new Date();
Date());
}
function CurentTime(){
var now = new Date();
var hh = Hours();
var mm = Minutes();
var ss = Time() % 60000;
ss = (ss - (ss % 1000)) / 1000;
var clock = hh+':';
if (mm < 10) clock += '0';
clock += mm+':';
if (ss < 10) clock += '0';
clock += ss;
return(clock);
}
function refreshCalendarClock(){
document.all.calendarClock1.innerHTML = Year_Month();
document.all.calendarClock2.innerHTML = Date_of_Today();
document.all.calendarClock3.innerHTML =thisYear();
document.all.calendarClock4.innerHTML = CurentTime(); }
document.write('<font id="calendarClock1" > </font> ');
document.write('<font id="calendarClock2" > </font>,');
document.write('<font id="calendarClock3" > </font> ');
document.write('<font id="calendarClock4" > </font>');
setInterval('refreshCalendarClock()',1000);
//-->
</SCRIPT>
<script language="javascript" src="./script/date.js"></script>
4. 现在时间:10:16:45 AM
<SCRIPT language=javascript>
<!--
function show5(){
if(!document.layers&&!document.all)
return
var Digital=new Date()
var Hours()
var Minutes()
var Seconds()
var dn="AM"
if(hours>12){dn="PM"
hours=hours-12
}if(hours==0)
hours=12
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
//change font size here to your desire
myclock="<font color=blue>现在时间:"+hours+":"+minutes+":"+seconds+" "+dn+"</font>";
if(document.layers){
document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("show5()",1000)
}
//-->
</SCRIPT>
<body onLoad=show5()>
<span id=liveclock style=position:absolute;left:250px;top:122px;; width: 109px; height: 15px>
</span>
5. 10:11:12
<head>
<script language=javaScript>
<!--//
function clockon() {
thistime= new Date()
var Hours()
var Minutes()
var Seconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
thistime = hours+":"+minutes+":"+seconds
if(document.all) {
bgclocknoshade.innerHTML=thistime
bgclockshade.innerHTML=thistime
}
if(document.layers) {
document.bgclockshade.document.write('<div id="bgclockshade" >'+thistime+'</div>')
document.bgclocknoshade.document.write('<div id="bgclocknoshade" >'+thistime+'</div>')
document.close()
}
var timer=setTimeout("clockon()",200)
}
//-->
</script>
</head>
<body bgcolor="#ffffff" onLoad="clockon()">
<div id="bgclockshade" ></div>
<div id="bgclocknoshade" ></div>
<div id="mainbody" >
</div>
</body>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论