w3schools php datetime code example
Example 1: time function in php
Return the current time as a Unix timestamp, then format it to a date:
<?php
/* Unix Timestamp */
$timestamp = time();
echo $timestamp . "<br>";
echo date("d/m/Y", $timestamp);
?>
Example 2: php date
$dateTime = new \DateTime();
/**
* You can get the string by using format
*/
$dateTime->format('Y-m-d H:i:s');