<!DOCTYPE html> <html> <body> <p>VBScripts' function <b>WeekdayName</b> is used to get a weekday:</p> <scripttype="text/vbscript"> document.write("<p>") document.write(weekdayname(1)) document.write("<br>") document.write(weekdayname(2)) document.write("</p><p>") document.write("Get the abbreviated name of a weekday:") document.write("<br>") document.write(weekdayname(1, true)) document.write("<br>") document.write(weekdayname(2, true)) document.write("</p><p>") document.write("Get the current weekday:") document.write("<br>") document.write(weekdayname(weekday(date))) document.write("<br>") document.write(weekdayname(weekday(date), true)) document.write("</p>") </script> </body> </html>
<!-- 运行结果: VBScripts' function WeekdayName is used to get a weekday: 星期日 星期一 Get the abbreviated name of a weekday: 周日 周一 Get the current weekday: 星期二 周二 -->
注意weekdayname函数的返回会根据是否提供第二个参数而变化。
显示月份和星期
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<!DOCTYPE html> <html> <body> <scripttype="text/vbscript"> document.write("Today's day is " & weekdayname(weekday(date))) document.write("<br>") document.write("The month is " &monthName(month(date))) </script> </body> </html>
<!-- 运行结果: Today's day is 星期二 The month is 十一月 -->
<!DOCTYPE html> <html> <body> <p>Countdown to year 3000:</p> <p> <scripttype="text/vbscript"> millennium=CDate("1/1/3000 00:00:00") document.write(millennium & "<br>") document.write("It is " & DateDiff("yyyy", Now(), millennium) & " years to year 3000!<br>") document.write("It is " & DateDiff("m", Now(), millennium) & " months to year 3000!<br>") document.write("It is " & DateDiff("d", Now(), millennium) & " days to year 3000!<br>") document.write("It is " & DateDiff("h", Now(), millennium) & " hours to year 3000!<br>") document.write("It is " & DateDiff("n", Now(), millennium) & " minutes to year 3000!<br>") document.write("It is " & DateDiff("s", Now(), millennium) & " seconds to year 3000!<br>") </script> </p> </body> </html> <!-- 运行结果: Countdown to year 3000: 3000/1/1 It is 978 years to year 3000! It is 11726 months to year 3000! It is 356889 days to year 3000! It is 8565322 hours to year 3000! It is 513919281 minutes to year 3000! It is 30835156829 seconds to year 3000! -->
<!DOCTYPE html> <html> <body> <scripttype="text/vbscript"> txt = "Have a nice day!" document.write(txt & "<br>") document.write(ucase(txt)) document.write("<br>") document.write(lcase(txt)) </script> </body> </html> <!-- Have a nice day! HAVE A NICE DAY! have a nice day! -->