I've had a book on PHP & MySQL for over a year, but I've barely touched it. Last night I decided to get to work on getting through the book as I've got some website ideas I'd like to pursue, but I currently lack the skills to execute what I want. Anyway, I've decided to pass on some of the knowledge I gain along the way.
In this post I'll show a simple piece of PHP code that will display the current date. I assume that this code depends upon the clock on the web server hosting the website, so if your server's clock is set to GMT, then the date may display incorrectly depending upon your time zone relative to GMT.
Displaying the date with PHP
This is the piece of code to display the date. I saved it in a text file called date.php on my development computer to try it out.
<?php echo date("F j, Y");?>
This will display the date in a form like: August 2, 2011. I'm not sure how to format the date in other ways. When I learn more, I'll pass it on.