Вход Регистрация
* -=(C)DRU987=- (Dev)

Вывод числа и месяца

  1. <SCRIPT>
  2. <!--
  3. setCal()
  4. function getTime() {
  5. // initialize time-related variables with current time settings
  6. var now = new Date()
  7. var hour = now.getHours()
  8. var minute = now.getMinutes()
  9. now = null
  10. var ampm = ""
  11.  
  12. // validate hour values and set value of ampm
  13. if (hour >= 12) {
  14. hour -= 12
  15. ampm = "PM"
  16. } else
  17. ampm = "AM"
  18. hour = (hour == 0) ? 12 : hour
  19.  
  20. // add zero digit to a one digit minute
  21. if (minute < 10)
  22. minute = "0" + minute // do not parse this number!
  23.  
  24. // return time string
  25. return hour + ":" + minute + " " + ampm
  26. }
  27.  
  28. function leapYear(year) {
  29. if (year % 4 == 0) // basic rule
  30. return true // is leap year
  31. /* else */ // else not needed when statement is "return"
  32. return false // is not leap year
  33. }
  34.  
  35. function getDays(month, year) {
  36. // create array to hold number of days in each month
  37. var ar = new Array(12)
  38. ar[0] = 31 // January
  39. ar[1] = (leapYear(year)) ? 29 : 28 // February
  40. ar[2] = 31 // March
  41. ar[3] = 30 // April
  42. ar[4] = 31 // May
  43. ar[5] = 30 // June
  44. ar[6] = 31 // July
  45. ar[7] = 31 // August
  46. ar[8] = 30 // September
  47. ar[9] = 31 // October
  48. ar[10] = 30 // November
  49. ar[11] = 31 // December
  50.  
  51. // return number of days in the specified month (parameter)
  52. return ar[month]
  53. }
  54.  
  55. function getMonthName(month) {
  56. // create array to hold name of each month
  57. var ar = new Array(12)
  58. ar[0] = "ЯНВАРЬ"
  59. ar[1] = "ФЕВРАЛЬ"
  60. ar[2] = "МАРТ"
  61. ar[3] = "АПРЕЛЬ"
  62. ar[4] = "МАЙ"
  63. ar[5] = "ИЮНЬ"
  64. ar[6] = "ИЮЛЬ"
  65. ar[7] = "АВГУСТ"
  66. ar[8] = "СЕНТЯБРЬ"
  67. ar[9] = "ОКТЯБРЬ"
  68. ar[10] = "НОЯБРЬ"
  69. ar[11] = "ДЕКАБРЬ"
  70.  
  71.  
  72. // return name of specified month (parameter)
  73. return ar[month]
  74. }
  75.  
  76. function setCal() {
  77. // standard time attributes
  78. var now = new Date()
  79. var year = now.getYear()
  80. var month = now.getMonth()
  81. var monthName = getMonthName(month)
  82. var date = now.getDate()
  83. now = null
  84.  
  85. // create instance of first day of month, and extract the day on which it occurs
  86. var firstDayInstance = new Date(year, month, 1)
  87. var firstDay = firstDayInstance.getDay()
  88. firstDayInstance = null
  89.  
  90. // number of days in current month
  91. var days = getDays(month, year)
  92. if (year < 2000)
  93. year = year + 1900;
  94. // call function to draw calendar
  95. drawCal(firstDay + 1, days, date, monthName, 0+ year)
  96. }
  97.  
  98. function drawCal(firstDay, lastDate, date, monthName, year) {
  99. // constant table settings
  100. var headerHeight = 40 // height of the table's header cell
  101. var border = 1 // 3D height of table's border
  102. var cellspacing = 1 // width of table's border
  103. var headerColor = "midnightblue" // color of table's header
  104. var headerSize = "+3" // size of tables header font
  105. var colWidth = 60 // width of columns in table
  106. var dayCellHeight = 25 // height of cells containing days of the week
  107. var dayColor = "darkblue" // color of font representing week days
  108. var cellHeight = 40 // height of cells representing dates in the calendar
  109. var todayColor = "red" // color specifying today's date in the calendar
  110. var timeColor = "blue" // color of font representing current time
  111. var bordercolor= "green" //color of main table
  112.  
  113. // create basic table structure
  114. var text = "" // initialize accumulative variable to empty string
  115. text += '<CENTER>'
  116. text += '<TABLE BORDER=' + border + ' CELLSPACING=' + cellspacing + ' BORDERCOLOR=' + bordercolor +'>' // table settings
  117. text += '<TH COLSPAN=7 HEIGHT=' + headerHeight + '>' // create table header cell
  118. text += '<FONT COLOR="' + headerColor + '" SIZE=' + headerSize + '>' // set font for table header
  119. text += monthName + ' ' + year
  120. text += '</FONT>' // close table header's font settings
  121. text += '</TH>' // close header cell
  122.  
  123. // variables to hold constant settings
  124. var openCol = '<TD WIDTH=' + colWidth + ' HEIGHT=' + dayCellHeight + '>'
  125. openCol += '<b><FONT COLOR="' + dayColor + '">'
  126. var closeCol = '</b></FONT></TD>'
  127.  
  128. // create array of abbreviated day names
  129. var weekDay = new Array(7)
  130. weekDay[0] = "Воскр."
  131. weekDay[1] = "Понед."
  132. weekDay[2] = "Втор."
  133. weekDay[3] = "Среда"
  134. weekDay[4] = "Четв."
  135. weekDay[5] = "Птн."
  136. weekDay[6] = "Суб."
  137.  
  138.  
  139. // create first row of table to set column width and specify week day
  140. text += '<TR bgcolor=lightgreen ALIGN="center" VALIGN="center">'
  141. for (var dayNum = 0; dayNum < 7; ++dayNum) {
  142. text += openCol + weekDay[dayNum] + closeCol
  143. }
  144. text += '</TR>'
  145.  
  146. // declaration and initialization of two variables to help with tables
  147. var digit = 1
  148. var curCell = 1
  149.  
  150. for (var row = 1; row <= Math.ceil((lastDate + firstDay - 1) / 7); ++row) {
  151. text += '<TR ALIGN="right" VALIGN="top">'
  152. for (var col = 1; col <= 7; ++col) {
  153. if (digit > lastDate)
  154. break
  155. if (curCell < firstDay) {
  156. text += '<TD></TD>';
  157. curCell++
  158. } else {
  159. if (digit == date) { // current cell represent today's date
  160. text += '<TD HEIGHT=' + cellHeight + '>'
  161. text += '<FONT COLOR="' + todayColor + '">'
  162. text += digit
  163. text += '</FONT><BR>'
  164. text += '<FONT COLOR="' + timeColor + '" SIZE=2>'
  165. text += '<CENTER>' + getTime() + '</CENTER>'
  166. text += '</FONT>'
  167. text += '</TD>'
  168. } else
  169. text += '<TD HEIGHT=' + cellHeight + '>' + digit + '</TD>'
  170. digit++
  171. }
  172. }
  173. text += '</TR>'
  174. }
  175.  
  176. // close all basic table tags
  177. text += '</TABLE>'
  178. text += '</CENTER>'
  179.  
  180. // print accumulative HTML string
  181. document.write(text)
  182. }
  183.  
  184.  
  185.  
  186. var mydate=new Date()
  187. var year=mydate.getYear()
  188. if (year < 2000)
  189. year = year + 1900;
  190. var day=mydate.getDay()
  191. var month=mydate.getMonth()
  192. if (month<10)
  193. month="0"+month
  194. var daym=mydate.getDate()
  195. if (daym<10)
  196. daym="0"+daym
  197. document.write("<center><small><font color='000000' face='Arial'><b>"+month+"/"+daym+"/"+year+"</b></font></small></center>")
  198. // -->
  199. </SCRIPT>
» Описание: Выводит текущее число и месяц
» Время добавления: 24 Окт 2015 в 17:21
» Посмотров: 1390
» textarea
» Рейтинг: [+0 | -0]
Комментарии [0]
Онлайн: 2
Реклама