Jump to content


Date functions

  • Please log in to reply
1 reply to this topic

#1 otuatail

  • Members
  • PipPipPip
  • Advanced Member
  • 960 posts

Posted 24 May 2006 - 09:01 AM

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.


#2 wisewood

  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 24 May 2006 - 10:26 AM

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;}


wisewood: proven fact, I am both wise, and wooden.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users