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


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().

Example

 Live Demo

if(date('j', $timestamp) === '1')
   echo "It is the first day of the month today
"; if(date('D', $timestamp) === 'Mon')    echo "It is Monday today
";

Output

This will produce the following output −

It is the first day of the month today

Updated on: 07-Apr-2020

670 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements