/    Sign up×
Community /Pin to ProfileBookmark

I am working on a callender just for the hey of it. I would like to make links to see the next month. But first I need to figure out how to find last month and next month. If some one could help me that would be great because I’ve been reading on php.net and I can’t really find it.

[url]www.momadddidley.com[/url] | [url]www.madddidley.com[/url]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@yunaSep 29.2004 — I'd start with date("m") to get the number of today's month, then add or subtract one from it. You'll obviously need to write some extra code for the end-of-year case. Something like:

[CODE]
$calyear=intval(date("Y"));
$thismonth=intval(date("m"));
$lastmonth=$thismonth-1;
$nextmonth=$thismonth+1;

# adjust for end of year
if ($thismonth==1) {
$lastmonth=12;
$calyear=$calyear-1;
}
if ($thismonth==12) {
$nextmonth=1;
$calyear=$calyear+1;
}

[/CODE]
×

Success!

Help @madddidley 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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