12-4 ???日??

ϥ JScript ت Date Aڭ̥iHɶMiUسBzCbUCdҤAڭ̨ϥΦAݪ JScript MΤݪ JavaScript Ӥ̮ɶPG

Example]time01.asp^G

WzdҪlɦpUG

lɡ]time01.asp^G]ǦϰUYi^
<%@language=jscript%>
<%title="AMΤݪɶ"%>
<!--#include file="head.inc"-->
<hr>

<%
today=new Date();
Response.Write("AɶG<font color=green>"+today.toLocaleString()+"</font>");
%>
<br>
<script>
today=new Date();
document.writeln("ΤݪɶG<font color=red>"+today.toLocaleString()+"</font>");
</script>

<hr>
<!--#include file="foot.inc"-->

bWzdҤAڭ̥ΦbAMΤݪ{XO@˪AOϥ new Date() ӥͤ@ӤAAϥ toLocaleString() kഫarC]Ѧ]iHݥX JavaScript/JScript bΤݩMA@q\C^

bUCdҤAڭ̷̨ӦAɶPAӦ^ǤPݭԻyG

Example]time03.asp^G

WzdҪlɦpUG

lɡ]time03.asp^G]ǦϰUYi^
<%@language=jscript%>
<%title="̷ӦAɶӦ^ǤPݭԻy"%>
<!--#include file="head.inc"-->
<hr>

<% today=new Date(); %>
Aݪ{bɶG<font color=green><%=today.toLocaleString()%></font><p>
<%
time=today.getHours();
if ((0<=time) && (time<2))
	greeting = "wgFAӺΤF!";
else if ((2<=time) && (time<4))
	greeting = "znѫGܡHֺΧa!"
else if ((4<=time) && (time<6))
	greeting = "ѧ֫GF! zO_A٬OߺΪΨ?"
else if ((6<=time) && (time<8))
	greeting = "z! @jMzNbsASPA믫OHP!"
else if ((8<=time) && (time<10))
	greeting = "z! WsASPĪG̦nAzO?"
else if ((10<=time) && (time<12))
	greeting = "Yɶ֨FAzjF?"
else if ((12<=time) && (time<13))
	greeting = "YF?OѤFY!"
else if ((13<=time) && (time<14))
	greeting = "Ȧw...ȺήɶAOn!"
else if ((14<=time) && (time<16))
	greeting = "Ȧw! zıΰܡHOεۤF!"
else if ((16<=time) && (time<18))
	greeting = "BʮɶAOu@F!"
else if ((18<=time) && (time<20))
	greeting = "zYL\F?ӦYF!"
else if ((20<=time) && (time<22))
	greeting = "ߦw! zYL\F?"
else if ((22<=time) && (time<24))
	greeting = "ߦw! ӺıF!"
else
	greeting = "zn!"
%>
<font size=+2><%= greeting %></font>

<hr>
<!--#include file="foot.inc"-->

ɶ󪺤kAbAMΤݪ JavaScript ΪkO@PAiUCdҡG

Example]time04.asp^G

WzdҪlɦpUG

lɡ]time04.asp^G]ǦϰUYi^
<%@language=jscript%>
<%title="JScript  Date 󪺦Uؤk"%>
<!--#include file="head.inc"-->
<hr>

<%
cmd=new Array();
i=0;
cmd[i++]="getDate()";
cmd[i++]="getDay()";
cmd[i++]="getHours()";
cmd[i++]="getMinutes()";
cmd[i++]="getMonth()";
cmd[i++]="getSeconds()";
cmd[i++]="getTime()";
cmd[i++]="getTimezoneOffset()";
cmd[i++]="getFullYear()";
cmd[i++]="toGMTString()";
cmd[i++]="toLocaleString()";

today=new Date();
for (i=0; i<cmd.length; i++){
	thisCmd="today."+cmd[i];
	Response.write(thisCmd+" ===> "+eval(thisCmd)+"<br>");
}
%>

<hr>
<!--#include file="foot.inc"-->

Hint
bAݪ JScript SΤ DOM (Document Object Model) AoOnSO`NBC

HWdҳOϥ JScript ASP ҤCYݭnAڭ̤]iHϥ VBScript ASP ҡAHɶMBzӨAVBScript ]ѤF@ǤبơAҦp timeBdateBnow AΥHǦ^{bɶMCҦpAYnܲ{bɶAi

<%=time%>
Ynܲ{bAi
<%=date%>
Ynϥ VBScript ӹFezu̷ӦAɶPӦ^ǤPݭԻyv\Adҥi time03_vbs.aspAbAحzC
JScript {]pPΡGΩAݪ ASP