View Single Post
  #12  
Old 04-04-2014, 03:40 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 22,610
IntoRain is on a distinguished road
Default

In the canWork() function, instead of working with the last time user worked, you'd compare today's date to the date you wanted.

PHP Code:
//get today's date, format returns the date in the specified format. m means month and d is day. So 'm-d' means 'month-day' format

$dateToday = new DateTime;
$dateTime $dateToday->format('m');//get the month only for example

//compare with the month we want
if($dateTime != '04')
{
//it's not april yet, can't work
}
else{
//it's april, can work
}

//or for month-day
$dateToday = new DateTime;
$dateTime $dateToday->format('m-d');//get the month only for example

//compare with the month we want
if($dateTime != '04-15')
{
//it's not april 15 yet, can't work
}
else{
//it's april 15, can work

__________________


asp.net stole my soul.
Reply With Quote