Bài soạn co de ngày giờ Hiện tại

2 397 0
Bài soạn co de ngày giờ Hiện tại

Đang tải... (xem toàn văn)

Thông tin tài liệu

<script LANGUAGE="JavaScript"> <!-- // Store the date In avarlable d = new Date() dateText = "" // Get the cuurent day and convert it to the name of the day dayValue = d.getDay() if(dayValue == 0) dateText += "chủ nhật" else if (dayValue == 1) dateText += "thứ hai" else if (dayValue == 2) dateText += "thứ ba" else if (dayValue == 3) dateText += "thứ tư" else if (dayValue == 4) dateText += "thứ năm" else if (dayValue == 5) dateText += "thứ sáu" else if (dayValue == 6) dateText += "thứ bảy" // Get the current date; if it's before 2000,add 1900 dateText += ", ngày " + d.getDate() // Get the current month and convert it to the name of the month monthValue = d.getMonth() dateText += " " if (monthValue == 0) dateText += "tháng 1" if (monthValue == 1) dateText += " tháng 2" if (monthValue == 2) dateText += " tháng 3" if (monthValue == 3) dateText += "tháng 4" if (monthValue == 4) dateText += "tháng 5" if (monthValue == 5) dateText += " tháng 6" if (monthValue == 6) dateText += "tháng 7" if (monthValue == 7) dateText += " tháng 8" if (monthValue == 8) dateText += "tháng 9" if (monthValue == 9) dateText += "tháng 10" if (monthValue == 10) dateText += " tháng 11" if (monthValue == 11) dateText += "tháng 12" // Get the current year; if it's before 2000, add 1900 if (d.getYear() < 2000) dateText += ", năm " + (1900 + d.getYear()) else dateText += ", năm " + (d.getYear()) // Get the current minutes minuteValue = d.getMinutes() if (minuteValue < 10) minuteValue = "0" + minuteValue // Get the current hours hourValue = d.getHours() // Customize the greeting based on the current hours if (hourValue < 12) { greeting = "Chào buổi sáng!" timeText = " Bây giờ " + hourValue + ":" + minuteValue + " AM" } else if (hourValue == 12) { greeting = "Chào buổi trưa!" timeText = " Bây giờ " + hourValue + ":" + minuteValue + " PM" } else if (hourValue < 14) { greeting = "Chào buổi trưa!" timeText = " Bây giờ " + (hourValue - 12) + ":" + minuteValue + " PM" } else if (hourValue < 18) { greeting = "Chào buổi chiều!" timeText = " Bây giờ " + (hourValue - 12) + ":" + minuteValue + " PM" } else { greeting = "Chào buổi tối!" timeText = " Bây giờ " + (hourValue - 12) + ":" + minuteValue + " PM" } // Write the greeting, the date, and the time to the page document.write(greeting + " Hôm nay là " + dateText + "." + timeText + ".") //--> </script> . it's before 2000,add 1900 dateText += ", ngày " + d.getDate() // Get the current month and convert it to the name of the month monthValue =. Bây giờ " + (hourValue - 12) + ":" + minuteValue + " PM" } else { greeting = "Chào buổi tối!" timeText = " Bây giờ

Ngày đăng: 22/11/2013, 12:11

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan