/    Sign up×
Community /Pin to ProfileBookmark

begin and end days

Ok. men…
i have this code..
this is for show the first day of the current week..(27)
it works .. now the need is for show the last day of the week..(1)
could any one help me with some advice.. to do this???
thaks for all coders!!!!!

Regards
RT


___________

<HEAD>

<SCRIPT LANGUAGE=”JavaScript”>

<!– Begin
page_extension = “.html”;
var today = new Date();
var day = today.getDate();
var month = today.getMonth() + 1;
var year = today.getYear();
if (year < 2000)

year = year + 1900;
var offset = today.getDay();
var week;

if(offset != 0) {
day = day – offset;
if ( day < 1) {
if ( month == 1) day = 31 + day;
if (month == 2) day = 31 + day;
if (month == 3) {
if (( year == 00) || ( year == 04)) {
day = 29 + day;
}
else {
day = 28 + day;
}
}
if (month == 4) day = 31 + day;
if (month == 5) day = 30 + day;
if (month == 6) day = 31 + day;
if (month == 7) day = 30 + day;
if (month == 8) day = 31 + day;
if (month == 9) day = 31 + day;
if (month == 10) day = 30 + day;
if (month == 11) day = 31 + day;
if (month == 12) day = 30 + day;
if (month == 1) {
month = 12;
year = year – 1;
}
else {
month = month – 1;
}
}
}

week = day + “-” + month + “-” + year; // i.e. 10-31-99

page = week + page_extension; // i.e. 10-31.99.html

link = “<a href='” + page + “‘>Page of the Week</a>”; // link to 10-31-99.html
// End –>
</script>
</HEAD>

<BODY>

<script>
document.write(week)

</script>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@CharlesAug 30.2006 — &lt;script type="text/javascript"&gt;
Date.prototype.getDayOfTheWeek = function (d) {
return new Date (this.getFullYear(), this.getMonth(), this.getDate() + d - this.getDay())
}

alert (new Date().getDayOfTheWeek(6).toDateString())
&lt;/script&gt;
Copy linkTweet thisAlerts:
@RterresauthorAug 30.2006 — Ok men!!!!!

many thanks!!!!!

i'll just custimize them to show both in a text field....

but this code helps so much!

Best regards!!!!!

Rodrigo T.
×

Success!

Help @Rterres spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...