Jump to content

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.

Desmond.

Link to comment
https://forums.phpfreaks.com/topic/10333-date-functions/
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.

[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]
Link to comment
https://forums.phpfreaks.com/topic/10333-date-functions/#findComment-38520
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.