PHP function of the day: date()

For day 14 of 21 in the “PHP Function of the day” series, I’m going to look at date(). The function takes a required format and an optional timestamp and outputs a formatted date.

Let’s take a look.

<?php

echo “This is the “.date(“d”).”th day of the month.”.”<br />”;

echo “This is the “.date(“m”).”th month of the year.”.”<br />”;

echo “The current year is “.date(“Y”).”<br />”;

echo “Today is “.date(“l”).”<br />”;

echo “Today is “.date(“Y/m/d”);

?>

 

See the output

 

There are a lot of ways to format a date.  The demo above just scratches the surface.  Have a question?  Feel free to leave a comment, below.

Leave a Reply

Your email address will not be published. Required fields are marked *