How to output the current date with PHP
In order to get the date from your server and display it on your website using PHP use the following snippet.
<?php echo date('F j, Y'); ?>
The above code will output "January 1, 2012" or whatever date your server thinks it is. This may not may not be formatted the way you would like so adjustments to the paremetters inside the date() function may need to be adjusted.
Here are some more options for displaying the date in PHP:
<?php echo date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm echo date("m.d.y"); // 03.10.01 echo date("j, n, Y"); // 10, 3, 2001 echo date("Ymd"); // 20010310 echo date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01 echo date('it is the jS day.'); // it is the 10th day. echo date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001 ?>
As you can see the PHP date function can also be configured to output time information as well. For more information about the date feature, head on over to PHP.net