If you want to display the current date, you can use the following code:
<?php $current_timestamp = date('m/d/Y h:i:s a', time()); echo $current_timestamp; ?>
The following will output something like:
07/30/2022 03:47:56 pm
By calling the time function with time(), you get the number of seconds since Unix Epoch (January 1 1970 00:00:00 GMT).
The date function formats the time, converting the seconds into the month, day, year, hour, minute, and second. You can control the display by changing the characters that represent what you want it to show.
|Format Character||Description||Example Returned Values|
|m||Numeric representation of a month, with leading zeros|
|d||Day of the month, 2 digits with leading zeros|
|Y||A full numeric representation of a year, at least 4 digits, with ||Examples: |
|h||12-hour format of an hour with leading zeros|
|i||Minutes with leading zeros|
|s||Seconds with leading zeros|
|a||Lowercase Ante meridiem and Post meridiem|
For a full list, you can refer to the PHP documentation, which can be found here.