Jump to content


This topic is now archived and is closed to further replies.


Date functions

Recommended Posts

I am strugling finding functions I have looked under Section VI. Function Reference

I have to do an events calender for a church. The events display will be limited to that week. If someone went in today Wed 24th I want to display 21st to 27th. I dont want any code samples, just the functions that find the day of week and a function that can (in this case) subtract 3 days to get sunday and add 7 for saterday. I can do the rest.


Share this post

Link to post
Share on other sites
I know you said you didnt want code, but i already had some code almost identical to this incorporated into one of my scripts, so i've copy/pasted it and made a couple of changes to suit what you wanted.

Hope this is of use.


$todays_date = date('d');
// Numerical representation of todays date (eg 24)
$today = date('D');
// The three letter day of the week (eg Wed)

// If today is Wed, start of week is -3 days and end of week is +3.
if($today=="Sun") {$start_date=$todays_date; $end_date=$todays_date+6;}
if($today=="Mon") {$start_date=$todays_date-1; $end_date=$todays_date+5;}
if($today=="Tue") {$start_date=$todays_date-2; $end_date=$todays_date+4;}
if($today=="Wed") {$start_date=$todays_date-3; $end_date=$todays_date+3;}
if($today=="Thu") {$start_date=$todays_date-4; $end_date=$todays_date+2;}
if($today=="Fri") {$start_date=$todays_date-5; $end_date=$todays_date+1;}
if($today=="Sat") {$start_date=$todays_date-6; $end_date=$todays_date;}


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.