/    Sign up×
Community /Pin to ProfileBookmark

Add days to posted variable

Hi.
I have a posted variable from another page with a date in it. It is in Y/m/d format.

[code=php]$var1 = $row_Recordset1[‘returndate’];[/code]

How do I add 14 days to that?

I would $VAR1 to equal $row_Recordset1[‘returndate’]; plus 14 days.

Thanks

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJul 17.2006 — convert it to a timestamp with [url=http://php.net/strtotime/]strtotime()[/url] then you can add 14 days and print it with the desired format
Copy linkTweet thisAlerts:
@metrostarsauthorJul 17.2006 — Hi,

How do you convert it to Timestamp?

Thanks
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJul 17.2006 — with the function i said (strtotime)
Copy linkTweet thisAlerts:
@NogDogJul 17.2006 — Or you could do it in your query. If you're using MySQL, use the ADDDATE() function:
[code=php]
$query = "SELECT <other columns>, ADDDATE(returndate, INTERVAL 14 DAY) AS plus_14_days FROM <etc....>";
[/code]
Copy linkTweet thisAlerts:
@metrostarsauthorJul 17.2006 — I'm a noob.

How do you use strtotime?
Copy linkTweet thisAlerts:
@NogDogJul 17.2006 — [code=php]
<?php
$date = "2007/07/17";
$twoWeeksLater = date("Y/m/d", strtotime("+ 14 days", strtotime($date)));
printf("%s plus 14 days is %s", $date, $twoWeeksLater);
?>
[/code]
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJul 18.2006 — http://www.php.net/manual/en/function.strtotime.php[/QUOTE]
linked to it in my first post...
Copy linkTweet thisAlerts:
@CharlesJul 18.2006 — linked to it in my first post...[/QUOTE]It needed repeating, metrostars seemed to miss the link.
×

Success!

Help @metrostars 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.20,
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,
)...