•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,094 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,267 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1532 | Replies: 6
![]() |
•
•
Join Date: Aug 2005
Posts: 17
Reputation:
Rep Power: 4
Solved Threads: 0
I'm trying to make a script to return the next 5 days for example today is 2006-04-24 and it would create variables with the values of 2006-04-25, 2006-04-26, 2006-04-27, 2006-04-28, 2006-04-29. I thought and using getdate function and add +1~5 to day value but I realized it would bug after the day gets over 30. Any suggestions?
•
•
Join Date: Aug 2004
Location: North Carolina
Posts: 27
Reputation:
Rep Power: 5
Solved Threads: 2
•
•
Join Date: Aug 2005
Posts: 76
Reputation:
Rep Power: 4
Solved Threads: 1
•
•
•
•
Originally Posted by StrikeFreedom
I'm trying to make a script to return the next 5 days for example today is 2006-04-24 and it would create variables with the values of 2006-04-25, 2006-04-26, 2006-04-27, 2006-04-28, 2006-04-29. I thought and using getdate function and add +1~5 to day value but I realized it would bug after the day gets over 30. Any suggestions?
I don't think checkdate will help greatly. Try mktime() instead.
The php manual entry for "date" reads:
It is possible to use date() and mktime() together to find dates in the future or the past. Example 3. date() and mktime()example
<?php
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
$nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1);
?>•
•
Join Date: Aug 2005
Posts: 76
Reputation:
Rep Power: 4
Solved Threads: 1
•
•
•
•
Originally Posted by JD.ua
Try this function:
int strtotime ( string time [, int now] )
How will this help in obtaining variables with consecutive dates in them?
•
•
Join Date: May 2006
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
you can do it like in such way
$dates_array = array();
for ($i=0; $i<5; $i++) {
$dates_array[] = date('Y-m-d', strtotime("+$i days"));
}![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: Newbie to PHP question
- Next Thread: online music library


Linear Mode