In PHP, you can use the date() function and the "==" operator to determine whether the specified timestamp is today. The syntax "if(date('Ymd', specified timestamp)==date( 'Ymd')){echo 'It's today';}else{echo 'Not today';}".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php determines the specified time Is the method of stamping today
Implementation idea:
Use date() to format today's date and convert it to "year and month" Day" format
Use date() to format the specified timestamp and convert it to "Year Month Day" format
Use "= The =” operator determines whether they are equal. If they are equal, the specified timestamp is today
Implementation code:
<?php header('content-type:text/html;charset=utf-8'); $timestamp = time(); // 获取一个时间戳 if(date('Ymd', $timestamp) == date('Ymd')) { echo '是今天'; }else{ echo '不是今天'; } ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to determine whether it is today given a specified timestamp in PHP. For more information, please follow other related articles on the PHP Chinese website!