Learn web design and programming with our free video and text tutorials.
Web Designer? Design and market your own professional website with easy-to-use tools.
Browse our HTML, XHTML and CSS tutorials to learn how to create your website at LearnWebsiteDesign.com or download one of our free website templates.
Providing high quality free software to download
PHP allows you to use the date() function to format a time and/or date.
The php date function accepts 2 arguments: date(format, timestamp).
The format argument is always required and specifies the format to display the date in.
The timestamp argument is optional and can be used as an alternate to the server time.
<?php
echo date("Y-m-d");
echo "<br />";
echo date("Y/m/d");
echo "<br />";
echo date("M d, Y");
echo "<br />";
echo date("F d, Y");
echo "<br />";
echo date("D M d, Y");
echo "<br />";
echo date("l F d, Y");
echo "<br />";
echo date("l F d, Y, h:i:s");
echo "<br />";
echo date("l F d, Y, h:i A");
?>
The code above creates the date and timestamps below:
2012-02-07
2012/02/07
Feb 07, 2012
February 07, 2012
Tue Feb 07, 2012
Tuesday February 07, 2012
Tuesday February 07, 2012, 12:46:37
Tuesday February 07, 2012, 12:46 AM