Professional Documents
Culture Documents
Dates
Dates
date_default_timezone_set("asia/hongkong")
print time();
<?php
$date_array = getdate(); // no argument passed so today's date will be used
foreach ( $date_array as $key => $val ) {
print "$key = $val<br/>";
}
?>
<hr/>
<p>
<?
print "Today's date: ";
print $date_array['mon']."/".$date_array['mday']."/".$date_array['year'];
?>
Format
Description
Example
am or pm lowercase
pm
AM or PM uppercase
PM
08
Wed
Month name
October
18
06
18
Minutes
31
j
Day of the month (no leading zeroes)
Wednesday
10
Oct
10
+0100
15
th
t
Number of days in the given month
31
BST
Unix timestamp
1065634275
Week of year
41
03
2003
280
3600
<?php
print date("m/d/y G.i:s", time());
// 10/08/03 19.17:42
print "<br/>";
print "Today is ";
print date("jS of F Y, \a\\t g.i a", time());
// Today is 8th of October 2003, at 7.17 pm
?>
hour
minute
second
month
day of month
year
<?php
// make a timestamp for 1/5/04 at 2.30 am
$ts = mktime( 2, 30, 0, 5, 1, 2004 );
print date("m/d/y G.i:s", $ts);
// 05/01/04 2.30:00
print "<br/>";
print "The date is ";
print date("jS of F Y, \a\\t g.i a", $ts );
// The date is 1st of May 2004, at 2.30 am
?>
checkdate( 4, 4, 1066 )