/    Sign up×
Community /Pin to ProfileBookmark

Return only Weekdays date

I need help to write a function that will return the days date, say “Friday, December 9”. But if it is a Saturday or Sunday it will return the following Mondays date. So say its Saturday, December 10 it will return “Monday, December 12”.

thank you.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bionoidDec 10.2011 — My version, with examples and everything ?

[code=php]function getFutureDate($time = 0)
{
if (!$time) {$time = time();}
$dow = (int)date('w', $time);
return date('l, F j', $time + (86400 * ($dow === 0 ? 1 : ($dow === 6 ? 2 : 0))));
}

echo getFutureDate() . '<br />'; //TODAY
echo getFutureDate(time() + (86400 * 1)) . '<br />'; //TOMORROW
echo getFutureDate(time() + (86400 * 2)) . '<br />'; //AFTER TOMORROW
echo getFutureDate(time() + (86400 * -1)) . '<br />'; //YESTERDAY
echo getFutureDate(time() + (86400 * -2)) . '<br />'; //BEFORE YESTERDAY[/code]


Function takes a unix timestamp, eg: time();
Copy linkTweet thisAlerts:
@TrueC11authorDec 10.2011 — Thank you a lot, works great ?
×

Success!

Help @TrueC11 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.29,
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,
)...