The HOUR constant in PHP represents the number of seconds in the hour, which is equal to 3600. Commonly used for time and date calculations, such as calculating timestamps, formatting date and time, time comparison, etc. In addition, PHP also provides other time unit constants, such as MINUTE, DAY, WEEK, MONTH, YEAR, etc.
HOUR in PHP
HOUR in PHP is a predefined constant that represents the number of seconds in the hour . Its value is equal to 3600, which is 1 hour = 60 minutes × 60 seconds.
HOUR constant is usually used in time and date calculations, for example:
Calculate timestamp:
<code class="php">$timestamp = time() + 3600; // 当前时间加 1 小时后的时间戳</code>
Format date and time:
<code class="php">$datetime = date('Y-m-d H:i:s', strtotime('+1 hour')); // 当前时间加 1 小时后的日期时间字符串</code>
Time comparison:
<code class="php">if (strtotime($datetime1) < strtotime($datetime2)) { // $datetime1 早于 $datetime2 }</code>
Other related constants:
PHP also provides some other related constants for representing different units of time:
The above is the detailed content of What does hour mean in php. For more information, please follow other related articles on the PHP Chinese website!