PHP Date and Time Tutorial

Optimizing and customizing your VPS/Dedicated server

PHP Date and Time Tutorial

Postby Mark » Fri Jan 01, 2010 1:41 am

Image


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 Code:
<?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:

2009-12-30
2009/12/30
Dec 30, 2009
December 30, 2009
Wed Dec 30, 2009
Wednesday December 30, 2009
Wednesday December 30, 2009, 06:45:08
Wednesday December 30, 2009, 06:45 AM
Mark
 
Posts: 124
Joined: Fri Dec 11, 2009 2:18 pm

Return to Configuring VPS/Dedicated servers

Who is online

Users browsing this forum: No registered users and 1 guest

cron