»
EnglishFrenchVietnamese

Print - Calender script that shows date and time of today - JavaScriptBank.com

Full version: jsB@nk » Time » Calendar » Calender script that shows date and time of today
URL: http://www.javascriptbank.com/calender-script-that-shows-date-and-time-of-today.html

Calender script that shows date and time of today © JavaScriptBank.comThis JavaScript will display a calender showing the date and time of today.

Full version: jsB@nk » Time » Calendar » Calender script that shows date and time of today
URL: http://www.javascriptbank.com/calender-script-that-shows-date-and-time-of-today.html



HTML
<SCRIPT language=JavaScript>/*Copyright 1996 - Tomer and Yehuda ShiranFeel free to "steal" this code provided that you leave this notice as is.Additional examples from the book can be found at http://www.geocities.com/SiliconValley/9000/For more information contact Tomer or Yehuda Shiran <yshiran@iil.intel.com>*/// Modified by Nguyen Truong Minh Chanh , photo_thinhan@yahoo.comsetCal()function getTime() {var now = new Date()var hour = now.getHours()var minute = now.getMinutes()now = nullvar ampm = "" if (hour >= 12) {hour -= 12ampm = "PM"} elseampm = "AM"hour = (hour == 0) ? 12 : hourif (minute < 10)minute = "0" + minute return hour + ":" + minute + " " + ampm}function leapYear(year) {if (year % 4 == 0) return true }function getDays(month, year) {var ar = new Array(12)ar[0] = 31ar[1] = (leapYear(year)) ? 29 : 28 ar[2] = 31 ar[3] = 30 ar[4] = 31 ar[5] = 30 ar[6] = 31 ar[7] = 31 ar[8] = 30 ar[9] = 31 ar[10] = 30 ar[11] = 31 return ar[month]}function getMonthName(month) {var ar = new Array(12)ar[0] = "Tháng M&#7897;t"ar[1] = "Tháng Hai"ar[2] = "Tháng Ba"ar[3] = "Tháng T&#432;"ar[4] = "Tháng N&#259;m"ar[5] = "Tháng Sáu"ar[6] = "Tháng B&#7843;y"ar[7] = "Tháng Tám"ar[8] = "Tháng Chín"ar[9] = "Tháng M&#432;&#7901;i"ar[10] = "Tháng M&#432;&#7901;i M&#7897;t"ar[11] = "Tháng M&#432;&#7901;i Hai"return ar[month]}function setCal() {var now = new Date()var year = now.getYear()if (year < 1000)year+=1900var month = now.getMonth()var monthName = getMonthName(month)var date = now.getDate()now = nullvar firstDayInstance = new Date(year, month, 1)var firstDay = firstDayInstance.getDay()firstDayInstance = nullvar days = getDays(month, year)drawCal(firstDay + 1, days, date, monthName, year)}function drawCal(firstDay, lastDate, date, monthName, year) {var headerHeight = 50var border = 2 var cellspacing = 4 var headerColor = "midnightblue" var headerSize = "+3" var colWidth = 60 var dayCellHeight = 25 var dayColor = "darkblue"var cellHeight = 40 var todayColor = "red" var timeColor = "purple"var text = "" text += '<CENTER>'text += '<TABLE BORDER=' + border + ' CELLSPACING=' + cellspacing + '>' text += '<TH COLSPAN=7 HEIGHT=' + headerHeight + '>' text += '<FONT COLOR="' + headerColor + '" SIZE=' + headerSize + '>' text += monthName + ' ' + year text += '</FONT>' text += '</TH>' var openCol = '<TD WIDTH=' + colWidth + ' HEIGHT=' + dayCellHeight + '>'openCol += '<FONT COLOR="' + dayColor + '">'var closeCol = '</FONT></TD>'var weekDay = new Array(7)weekDay[0] = "Ch&#7911; Nh&#7853;t"weekDay[1] = "Th&#7913; Hai"weekDay[2] = "Th&#7913; Ba"weekDay[3] = "Th&#7913; T&#432;"weekDay[4] = "Th&#7913; N&#259;m"weekDay[5] = "Th&#7913; Sáu"weekDay[6] = "Th&#7913; B&#7843;y"text += '<TR ALIGN="center" VALIGN="center">'for (var dayNum = 0; dayNum < 7; ++dayNum) {text += openCol + weekDay[dayNum] + closeCol }text += '</TR>'var digit = 1var curCell = 1for (var row = 1; row <= Math.ceil((lastDate + firstDay - 1) / 7); ++row) {text += '<TR ALIGN="right" VALIGN="top">'for (var col = 1; col <= 7; ++col) {if (digit > lastDate)breakif (curCell < firstDay) {text += '<TD></TD>';curCell++} else {if (digit == date) { text += '<TD HEIGHT=' + cellHeight + '>'text += '<FONT COLOR="' + todayColor + '">'text += digittext += '</FONT><BR>'text += '<FONT COLOR="' + timeColor + '" SIZE=2>'text += '<CENTER>' + getTime() + '</CENTER>'text += '</FONT>'text += '</TD>'} elsetext += '<TD HEIGHT=' + cellHeight + '>' + digit + '</TD>'digit++}}text += '</TR>'}text += '</TABLE>'text += '</CENTER>'document.write(text) }</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->