Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // JavaScript Document
  2.  
  3.  
  4. function currentDate() {
  5.   current_time = new Date()
  6.   hour = current_time.getHours()
  7.   if (hour <= 9)
  8.   hour = "0" + hour
  9.    
  10.   minutes = current_time.getMinutes()
  11.   if (minutes <= 9)
  12.   minutes = "0" + minutes
  13.    
  14.   seconds = current_time.getSeconds()
  15.   if (seconds <= 9)
  16.   seconds = "0" + seconds
  17.    
  18.   year = current_time.getYear()
  19.   if (year < 1000)
  20.   year += 1900
  21.    
  22.   month = current_time.getMonth()
  23.    
  24.   day = current_time.getDay()
  25.    
  26.   day_month = current_time.getDate()
  27.   if (day_month <= 9)
  28.   day_month = "0" + day_month
  29.  
  30.   day_array = ["Domingo", "Segunda-feira", "Terça-Feira", "Quarta-feira", "Quinta-feira", "Sexta-Feira", "Sábado"]
  31.    
  32.   month_array = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]
  33.  
  34.   if (hour < 12)
  35.   printable_time = day_array[day] + ", " + day + " de " + month_array[month] + " de " + year + " - " + hour + ":" + minutes + ":" + seconds + " - " + "Bom Dia!"
  36.   else if (hour >= 12 && hour < 19)
  37.   printable_time = day_array[day] + ", " + day + " de " + month_array[month] + " de " + year + " - " + hour + ":" + minutes + ":" + seconds + " - " + "Boa Tarde!"
  38.   else if (hour >= 19 && hour <= 24)
  39.   printable_time = day_array[day] + ", " + day + " de " + month_array[month] + " de " + year + " - " + hour + ":" + minutes + ":" + seconds + " - " + "Boa Noite!"
  40.  
  41.   document.form_date.date.value = printable_time
  42.  
  43.   setTimeout("currentDate()",1000)
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement