Can someone point me in the right direction on this question? I am building a "weekly message" CMS for a church web site. Their week starts on Sunday and they want to be able to post the Pastors sermon (or notes) for this weeks service on their web site.
What I would like to do is have the page load the message that falls on last Sunday all week long (until the next Sunday, when it loads the next week's message). I would also like to title the page "Weekly Message for Mmm, dd, YYYY" where the date is the most recent Sunday. All of the data will be stored in a MySQL table (unless the printed weekly date does not need to be).
I am drawing a total blank on how to do this. All help would be most appreciated.
[SOLVED] HELP NEEDED - Date Manipulation
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
<?php
echo date('M d, Y H:i:s', strtotime('last sunday'));
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
OK, lets take it a step further. In the CMS I want to allow the admin to select a Sunday from a select option list. The list should contain all sundays for the year. I was thinking of using a for loop with the start pointer as 'Next Sunday', but I am not sure how to set the constraint parameter to keep the date list to this year only. Any suggestions?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
[SOLVED] - Date Manipulation
I figured out what I want to do. Sorry for not posting back sooner. This is what I was looking for:
I hope this helps someone out. This returns all Sundays with a unixtimestamp less than the first Sunday of Next Year.
Code: Select all
<?php
echo '<select name="date">';
for ($date = strtotime('next Sunday'); $date < mktime(0,0,0,1,1,(date('Y')+1)); $date + 604800)
{
echo '<option value="' . $date . '">' . date('l, F jS, Y', $date) . '</option>';
}
echo '</select>';
?>