Last active
August 29, 2015 14:01
-
-
Save theverything/087ac1972695122ea205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Prepare greeting | |
var today = new Date(); | |
if (today.getDay()==0) day="Sunday"; | |
if (today.getDay()==1) day="Monday"; | |
if (today.getDay()==2) day="Tuesday"; | |
if (today.getDay()==3) day="Wednesday"; | |
if (today.getDay()==4) day="Thursday"; | |
if (today.getDay()==5) day="Friday"; | |
if (today.getDay()==6) day="Saturday"; | |
if (today.getMonth()==0) month="January"; | |
if (today.getMonth()==1) month="February"; | |
if (today.getMonth()==2) month="March"; | |
if (today.getMonth()==3) month="April"; | |
if (today.getMonth()==4) month="May"; | |
if (today.getMonth()==5) month="June"; | |
if (today.getMonth()==6) month="July"; | |
if (today.getMonth()==7) month="August"; | |
if (today.getMonth()==8) month="September"; | |
if (today.getMonth()==9) month="October"; | |
if (today.getMonth()==10) month="November"; | |
if (today.getMonth()==11) month="December"; | |
var year = today.getYear(); | |
if (year < 50) { | |
year = 0+year; | |
}else{ | |
year = 0+year; | |
} | |
if (year == 100) year = 2000 | |
if (year == 101) year = 2001 | |
if (year == 102) year = 2002 | |
if (year == 103) year = 2003 | |
if (year == 104) year = 2004 | |
if (year == 105) year = 2005 | |
if (year == 106) year = 2006 | |
if (year == 107) year = 2007 | |
if (year == 108) year = 2008 | |
if (year == 109) year = 2009 | |
if (year == 110) year = 2010 | |
if (year == 111) year = 2011 | |
if (year == 112) year = 2012 | |
if (year == 113) year = 2013 | |
if (year == 114) year = 2014 | |
if (year == 115) year = 2015 | |
if (year == 116) year = 2016 | |
if (year == 117) year = 2017 | |
if (year == 118) year = 2018 | |
if (year == 119) year = 2019 | |
var hour =today.getHours(); | |
var greeting;if (hour < 6) | |
greeting = "Good Early Morning!"; | |
else if (hour < 11) | |
greeting = "Good Morning!"; | |
else if (hour < 12) | |
greeting = "Lunch Time!"; | |
else if (hour < 16) | |
greeting = "Good Afternoon!"; | |
else if (hour < 18) | |
greeting = "Good Late Afternoon!"; | |
else | |
greeting = "Good Evening!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Prepare greeting | |
var DAYS = [ | |
"Sunday", | |
"Monday", | |
"Tuesday", | |
"Wednesday", | |
"Thursday", | |
"Friday", | |
"Saturday" | |
]; | |
var MONTHS = [ | |
"January", | |
"February", | |
"March", | |
"April", | |
"May", | |
"June", | |
"July", | |
"August", | |
"September", | |
"October", | |
"November", | |
"December" | |
]; | |
var today = new Date(); | |
var month = MONTHS[today.getMonth()]; | |
var day = DAYS[today.getDay()]; | |
var year = '20' + today.getYear().toString().slice(1); | |
var hour = today.getHours(); | |
var greeting; | |
if (hour < 6) { | |
greeting = "Good Early Morning!"; | |
} else if (hour < 11) { | |
greeting = "Good Morning!"; | |
} else if (hour < 12) { | |
greeting = "Lunch Time!"; | |
} else if (hour < 16) { | |
greeting = "Good Afternoon!"; | |
} else if (hour < 18) { | |
greeting = "Good Late Afternoon!"; | |
} else { | |
greeting = "Good Evening!"; | |
} | |
document.write ("<H3><center>"+greeting+"<br>It is "+day+", "+month+" "+today.getDate()+" "+year+"</center></H3>"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment