get today's date in php

To get today's date in PHP, you can use the date() function with the 'Y-m-d' format parameter. This will return today's date in the format YYYY-mm-dd.

main.php
$date = date('Y-m-d');
echo $date;
35 chars
3 lines

Output:

main.php
2021-08-06
11 chars
2 lines

You can also customize the format parameter to get the date in a different format. You can find more information on the available format parameters in the PHP documentation for the date() function.

gistlibby LogSnag