otuatail Posted May 24, 2006 Share Posted May 24, 2006 I am strugling finding functions I have looked under Section VI. Function ReferenceI 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.Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/10333-date-functions/ Share on other sites More sharing options...
wisewood Posted May 24, 2006 Share Posted May 24, 2006 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.[code]<?php$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;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10333-date-functions/#findComment-38520 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.