Date and Time in PHP
PHP provides built-in functions to work with date and time. You can format dates and times, calculate time differences, and perform other operations.
Example:
php
// get the current date and time
$date = date("Y-m-d H:i:s");
echo $date; // output: 2023-04-05 15:30:00
// calculate the time difference between two dates
$date1 = new DateTime("2023-01-01");
$date2 = new DateTime("2023-04-05");
$diff = $date2->diff($date1);
echo $diff->format("%a days"); // output: 94 days
No comments:
Post a Comment