PHP/Date/localtime
Содержание
Changing time zone with an environment variable
<source lang="html4strict">
<?php putenv("TZ=PST8PDT"); $california_time_parts = localtime(); ?>
</source>
Finding time parts
<source lang="html4strict">
<?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]"; ?>
</source>
Return array from localtime( )
<source lang="html4strict">
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?
</source>
Simple time zone calculation
<source lang="html4strict">
<?php $time_parts = localtime(); $california_time_parts = localtime(time() - 3 * 3600); ?>
</source>
Using localtime()
<source lang="html4strict">
<?php $a = localtime(); $a[4] += 1; $a[5] += 1900; print "$a[4]/$a[3]/$a[5]";
</source>