Skip to content

Instantly share code, notes, and snippets.

@petermd
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petermd/bc4ea9199ca03cbbbd45 to your computer and use it in GitHub Desktop.
Save petermd/bc4ea9199ca03cbbbd45 to your computer and use it in GitHub Desktop.
leet javascript
$(document).ready(function () {
//var end = new Date.getHours();
var currentMonth = (new Date).getMonth() + 1;
var currentDay = (new Date).getDate(); // create an instance of the date object
var datetoday = new Date(); // create new Date()
var timenow = datetoday.getTime(); // grabbing the time it is now
datetoday.setTime(timenow); // setting the time now to datetoday variable
var hournow = datetoday.getHours(); //the hour it is
var month = $('.CurrentMonth');
switch (currentMonth) {
case 1:
month.text('January');
break;
case 2:
month.text('February');
break;
case 3:
month.text('March');
break;
case 4:
month.text('April');
break;
case 5:
month.text('May');
break;
case 6:
month.text('June');
break;
case 7:
month.text('July');
break;
case 8:
month.text('August');
break;
case 9:
month.text('September');
break;
case 10:
month.text('October');
break;
case 11:
month.text('November');
break;
case 12:
month.text('December');
break;
default:
month.text(currentMonth);
}
if (hournow >= 18) { // if it is after 6pm
$('.CurrentDay').text(currentDay + 1);
}
else {$('.CurrentDay').text(currentDay);}
var nextDay = $('.CurrentDay');
console.log(currentDay);
if((currentDay) == 1 && (hournow >= 18)) {
$('.CurrentDay').text(currentDay + 1);
nextDay.append('nd');
}
else if((currentDay) == 2 && (hournow >= 18)) {
$('.CurrentDay').text(currentDay + 1);
nextDay.append('rd');
}
else if((currentDay) == 3 && (hournow >= 18)) {
$('.CurrentDay').text(currentDay + 1);
nextDay.append('th');
}
else if((currentDay) == 20 && (hournow >= 18)) {
$('.CurrentDay').text(currentDay + 1);
nextDay.append('st');
}
else if((currentDay) == 21 && (hournow >= 18)) {
$('.CurrentDay').text(currentDay + 1);
nextDay.append('nd');
}
else if((currentDay) == 22 && (hournow >= 18)) {
$('.CurrentDay').text(currentDay + 1);
nextDay.append('rd');
}
else if((currentDay) == 23 && (hournow >= 18)) {
$('.CurrentDay').text(currentDay + 1);
nextDay.append('th');
}
else if((currentDay) == 31 && (hournow >= 18)) {
$('.CurrentDay').text(currentDay + 1);
nextDay.append('st');
}
else if((currentDay) == 21){nextDay.append('st');}
else if((currentDay) == 31){nextDay.append('st');}
else if((currentDay) == 2) {nextDay.append('nd');}
else if((currentDay) == 22){nextDay.append('nd');}
else if((currentDay) == 3){nextDay.append('rd');}
else if((currentDay) == 23){nextDay.append('th');}
else if((currentDay) == 1) {nextDay.append('st');}
else if((currentDay) == 21){nextDay.append('st');}
else if((currentDay) == 31){nextDay.append('st');}
else if((currentDay) == 2) {nextDay.append('nd');}
else if((currentDay) == 22){nextDay.append('nd');}
else if((currentDay) == 3){nextDay.append('rd');}
else if((currentDay) == 23){nextDay.append('th');}
else{nextDay.append('th');}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment