Script Categories













Date & Time >>> Week Dates.

Displays the start and end dates for the current week. Code updated to be more efficient and shorter, too.

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function formatDate(date) {
var mymonth = date.getMonth()+1;
var myweekday = date.getDate();
return (mymonth + "/" + myweekday);
}
function printWeek() {
var now = new Date();
var nowDayOfWeek = now.getDay();
var nowDay = now.getDate();
var nowMonth = now.getMonth();
var nowYear = now.getYear();
nowYear += (nowYear < 2000) ? 1900 : 0;
var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
document.write("<b>Current Week:  " + formatDate(weekStartDate) + " - " + formatDate(weekEndDate)+"</b>");
}
printWeek();
//  End -->
</script>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©