I have been looking through examples online, and I am finding them a bit cryptic or overkill.
What I need to do is something like this:
$timestamp = time();
and then find out if the day is a Monday or a fist of the month?
I am sure it is possible, I am just not sure how to do that.
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";
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 =/
}
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..
You can use: strtotime
$firstdaymonth = strtotime('first day this month');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With