Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in PHP only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
PHP
date calculation functions
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
vgshri
New Member
Join Date:
Sep 2006
Posts:
2
#1
date calculation functions
Mar 9 '07, 10:39 AM
Hi all,
Can anyone help me to calculate the date after months.
Thanks in Advance
savanm
New Member
Join Date:
Oct 2006
Posts:
85
#2
Mar 9 '07, 11:45 AM
Hi
try this
$nextweek = time()+(7*24*60 *60);
echo 'Next week'.date('d-m-Y',$nextweek)." \n";
$nextmonth = time()+(30*24*6 0*60);
echo 'Next month'.date('d-m-Y',$nextmonth). "\n";
Regards
savanm: enclose your code with code or php tags!! - moderator
Comment
Post
Cancel
ronverdonk
Recognized Expert
Specialist
Join Date:
Jul 2006
Posts:
4259
#3
Mar 9 '07, 09:25 PM
Originally posted by
savanm
Hi
try this
$nextweek = time()+(7*24*60 *60);
echo 'Next week'.date('d-m-Y',$nextweek)." \n";
$nextmonth = time()+(30*24*6 0*60);
echo 'Next month'.date('d-m-Y',$nextmonth). "\n";
Regards
savanm: enclose your code with code or php tags!! - moderator
That is not going to work! Think about current date like 1 Jan, 31 Jan, etc.
Instead use the standard PHP strtotime function and format the result. Like this:
[php]<?php
echo "1 week from now = " . date("Y-m-d", strtotime("+1 week"));
echo '<br />';
echo "1 month from now = " . date("Y-m-d", strtotime("+ 1 month"));
?>[/php]
For more information on how to use the strtotime command, see
strtorime function
in the standard PHP manual.
Ronald :cool:
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment