vbnullchar Posted February 5, 2007 Share Posted February 5, 2007 how can i return the dates of week week #30.. Link to comment https://forums.phpfreaks.com/topic/37130-returning-dates/ Share on other sites More sharing options...
phat_hip_prog Posted February 5, 2007 Share Posted February 5, 2007 Here's some code you could loop: <?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); ?> Code from: http://uk2.php.net/manual/en/function.date.php Link to comment https://forums.phpfreaks.com/topic/37130-returning-dates/#findComment-177354 Share on other sites More sharing options...
obsidian Posted February 5, 2007 Share Posted February 5, 2007 how can i return the dates of week week #30.. Can you be a little more specific? Are you wanting to pull week #30 of the year and display the dates of that week? What days, etc... the more details you can give, the better chance we have of being able to get you a working code. Here is something you may wish to consider, though: <?php // Exactly week 30 would be the 210st day of the year (7 * 30) $start_day = 7 * 30; // Get the timestamp for that day $start_ts = mktime(0,0,0,1,$start_day,date('Y')); $day = 60 * 60 * 24; // One day of time $week = $day * 7; // One week of time // Loop through one week of time by day for ($today = $start_ts; $today < $start_ts + $week; $today += $day) { echo date('D M j, Y', $today) . "<br />\n"; } ?> Hope that helps Link to comment https://forums.phpfreaks.com/topic/37130-returning-dates/#findComment-177368 Share on other sites More sharing options...
vbnullchar Posted February 6, 2007 Author Share Posted February 6, 2007 how can i get the starting date of week 06 $start_day = 7 * date('W'); // Get the timestamp for that day $start_ts = mktime(0,0,0,1,$start_day,date('Y')); $day = 60 * 60 * 24; // One day of time $week = $day * 7; // One week of time // Loop through one week of time by day for ($today = $start_ts; $today < $start_ts + $week; $today += $day) { echo date('D M j, Y', $today) . "<br />\n"; } this returns: Sun Feb 11, 2007 Mon Feb 12, 2007 Tue Feb 13, 2007 Wed Feb 14, 2007 Thu Feb 15, 2007 Fri Feb 16, 2007 Sat Feb 17, 2007 Link to comment https://forums.phpfreaks.com/topic/37130-returning-dates/#findComment-178024 Share on other sites More sharing options...
JasonLewis Posted February 6, 2007 Share Posted February 6, 2007 try replacing date('W') with 6. thats what obsidian's code is asknig for, i think. Link to comment https://forums.phpfreaks.com/topic/37130-returning-dates/#findComment-178026 Share on other sites More sharing options...
obsidian Posted February 6, 2007 Share Posted February 6, 2007 try replacing date('W') with 6. thats what obsidian's code is asknig for, i think. Right. In your initial post, you asked for week #30, that's why I had 7 * 30. Then, in your latest post, you've got date('W'), which is the current week of the year. If you want to just display the first date, don't run through your loop and just output the $start_ts for the first day of the given week. Link to comment https://forums.phpfreaks.com/topic/37130-returning-dates/#findComment-178194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.