Source Code:
(back to article)
<?php $timestamp = time(); // Use the current time, or replace with your own timestamp // Calculate the beginning of the day $beginning_of_day = date('Y-m-d H:i:s', strtotime("midnight", $timestamp)); // Calculate the end of the day $end_of_day = date('Y-m-d H:i:s', strtotime("tomorrow", $timestamp) - 1); // Output the beginning and end of the day echo "Beginning of day: " . $beginning_of_day . "\n"; echo "End of day: " . $end_of_day . "\n"; // Output: // Beginning of day: [current year]-[current month]-[current day] 00:00:00 // End of day: [current year]-[current month]-[current day] 23:59:59 ?>
Result:
Report an issue