/    Sign up×
Community /Pin to ProfileBookmark

+7 Days on a date

Hi Guys,

Im trying to figure out the easiest way of adding 7 days onto a date. I supply a start date then id like to get the date for each subsequent week.. I thought adding 7 days onto the previous weeks date would be the best way but im not sure!

Thoughts?
Thanks! Scotty

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@kaafmimNov 04.2009 — I assume you have chosen wrong tag for your question. This is either a PHP or a JavaScript question. Not a CSS question for sure.

I think you mean in js, if so, the answer is very simple:
[CODE]
var myDate=new Date();
myDate.setDate(myDate.getDate()+7);
[/CODE]

Don't bother yourself so much, javascript date class does everything! After doing so, javascript engine calculates the date of 7 days later.

In case you need a PHP code here it is:

[CODE]<?php
$myDate = mktime(0,0,0,date("m"),date("d")+7,date("Y"));
echo $myDate;
?>
[/CODE]

This one does the same. But in this case it also echos $myDate, you may remove that echo line, and do whatever you want with it.
×

Success!

Help @SRobinson 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...