Monthly Cut Off for a web system

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
acellec
php-forum Active User
php-forum Active User
Posts: 26
Joined: Thu May 17, 2012 5:44 pm

Sun Jun 03, 2012 5:41 pm

Can you help me implement a monthly cut off using php mysql?

What i want to do is to every 4th of the month a user cannot submit or create any submission.

Help me Please?
User avatar
Nullsig
php-forum GURU
php-forum GURU
Posts: 979
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Mon Jun 04, 2012 10:15 am

Code: Select all

if(date("d",strtotime("now")) == 4){
       echo "You cannot submit today";
}else{
       echo "You can submit today";
}
acellec
php-forum Active User
php-forum Active User
Posts: 26
Joined: Thu May 17, 2012 5:44 pm

Mon Jun 04, 2012 4:05 pm

Nullsig wrote:

Code: Select all

if(date("d",strtotime("now")) == 4){
       echo "You cannot submit today";
}else{
       echo "You can submit today";
}
how about if for example,
i created a submission for this month of june if i dont submit before july 4 then my submission will expire and cannot be submitted.

this goes also if for example i created submission month of july if i dont submit before august 8 then my submission wil expire and cannot be submitted.
User avatar
ejsexton82
php-forum Fan User
php-forum Fan User
Posts: 86
Joined: Mon Jun 04, 2012 10:05 pm
Location: Ankara, Turkey
Contact:

Mon Jun 04, 2012 11:04 pm

Let's say that you have a creation date:

Code: Select all

$creationDate = date('m/d/Y');
Then you could check the creation date upon submission:

Code: Select all

// Expiration time is one month after the creation time
$expirationTime = strtotime("{$creationDate} +1 month");

// Check the expiration time at submission
if($_SERVER['REQUEST_TIME'] <= $expirationTime) {
	echo 'Can submit!';
} else {
	echo 'Submission expired!';
}
acellec
php-forum Active User
php-forum Active User
Posts: 26
Joined: Thu May 17, 2012 5:44 pm

Tue Jun 05, 2012 4:39 pm

thanks for the help. I will try that :)
Post Reply