PHP - How to use $timestamp to check if today is Monday or 1st of the month?

PHPServer Side ProgrammingProgramming

The date function can be used to return the string formatted based on the format specified by providing the integer timestamp or the current time if no timestamp is given

The timestamp is optional and defaults to the value of time().


 Live Demo

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 will produce the following output −

It is the first day of the month today
Published on 07-Apr-2020 11:05:17