PHP/Date/localtime
Содержание
Changing time zone with an environment variable
<?php
putenv("TZ=PST8PDT");
$california_time_parts = localtime();
?>
Finding time parts
<?php
$now_1 = getdate();
$now_2 = localtime();
print "{$now_1["hours"]}:{$now_1["minutes"]}:{$now_1["seconds"]}\n";
print "$now_2[2]:$now_2[1]:$now_2[0]";
?>
Return array from localtime( )
Numeric position Key Value
0 tm_sec Second
1 tm_min Minutes
2 tm_hour Hour
3 tm_mday Day of the month
4 tm_mon Month of the year (January is 0)
5 tm_year Years since 1900
6 tm_wday Day of the week (Sunday is 0)
7 tm_yday Day of the year
8 tm_isdst Is daylight savings time in effect?
Simple time zone calculation
<?php
$time_parts = localtime();
$california_time_parts = localtime(time() - 3 * 3600);
?>
Using localtime()
<?php
$a = localtime();
$a[4] += 1;
$a[5] += 1900;
print "$a[4]/$a[3]/$a[5]";