Tag Archives: Functions

DateTimeZone::listAbbreviations

It returns associative array containing dst, offset and the timezone name
Example

<?php
echo “<pre>”;
$ta = DateTimeZone::listAbbreviations();
print_r($ta[“burt”]);
?>

Output

Array
(
[0] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Kolkata
)

[1] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Calcutta
)

[2] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Dacca
)

[3] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Dhaka
)

[4] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Rangoon
)

)

strftime

It formats a local time/date according to locale settings
Example

<?php
setlocale(LC_TIME, “C”);
echo strftime(“%A”);
?>

Below given are the the formats

%a,%A,%d,%e,%j,%u,%w,%U,%V,%W,%b,%B,%h,%m,%C,%g,%G,%y,%Y,%H,%I,%l,%M,%p,%P,%r,%R,%S,%T,%X,%z,%Z

Output

Wednesday

idate

It formats a local time/date as integerExample

<?php
$timestamp = strtotime(‘1st January 2007’);
echo idate(‘y’, $timestamp);
?>

Below given are the format characters

B,d,h,H,i,I,L,m,s,t,U,w,W,y,Y,z,Z

Output

7

gmstrftime

it formats a GMT/UTC time/date according to locale settings
Example

<?php
setlocale(LC_TIME, ‘en_US’);
echo strftime(“%b %d %Y %H:%M:%S”, mktime(17, 0, 0, 12, 31, 97)) . “<br />”;
echo gmstrftime(“%b %d %Y %H:%M:%S”, mktime(17, 0, 0, 12, 31, 97)) ;
?>

Output

Dec 31 1997 17:00:00
Dec 31 1997 11:30:00