PHP - how to use $timestamp to check if today is Monday or 1st of the month?
This should solve it:
$day = date('D');
$date = date('d')
if($day == Mon){
//Code for monday
}
if($date == 01){
//code for 1st fo the month
}
else{
//not the first, no money for you =/
}
You can use: strtotime
$firstdaymonth = strtotime('first day this month');
This will grab.. Monday from mysql
$monday = 1; //tuesday= 2.. sunday = 7
AND $monday = (date_format(from_unixtime(your_date_column),'%w'))
OR days..
$day = 1; ///1st in month
AND $day = (date_format(from_unixtime(your_date_column),'%d'))
JUST TO KNOW
$date = date("d"); //1st?
$dayinweek = date("w"); //monday? //as a number in a week what you need more then just "Monday" I guess..
Actually, you don't need timestamp variable because:
Exerpt from date function of php.net:
Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time().
if(date('j', $timestamp) === '1')
echo "It is the first day of the month today\n";
if(date('D', $timestamp) === 'Mon')
echo "It is Monday today\n";