PHP Date & Times
PHP date() function returns current or specified date and time. Before use date(), the default time zone must be set by
date_default_timezone_set().
<?PHP
date_default_timezone_set("America/New_York");
$d=date("Y/m/d");
echo $d; //2000/09/06
?>
string date(string format[, int timestamp]), if the 2nd parameter is not specified, the returned time is current time. The complete list of
date format:
d
day with 2 digits, 01-31
D
3 character week day, e.g. Fri
F
Month name, e.g. January
I
DST applied in current time zone or not, 1 is yes, 0 is no
L
leap year or not, 1 is yes, 0 is no
S
th, st, nd of such as 1st, 2nd, 4th
t
total days of a month, 28-31
T
current time zone of the server
Z
time zone offset by seconds, ~43200 - 43200
time() function returns the seconds from 01/01/1970 00:00:00 GMT.
microtime() function returns the seconds and microsends from 01/01/1970 00:00:00 GMT.
<?PHP
echo time(); //1300050832
echo microtime(); //0.41567500 1300050898
?>
getdate() function returns an array of current or specified time information.
<?PHP
date_default_timezone_set("America/New_York");
$arr = getdate(1000050898);
print_r($arr);
//Array ( [seconds] => 58 [minutes] => 54 [hours] => 11 [mday] => 9 [wday] => 0 [mon] => 9 [year] => 2001 [yday] => 251 [weekday] => Sunday [month] => September [0] => 1000050898 ) 0//echo microtime(); //0.41567500 1300050898
echo $arr["wday"]; //0
?>