<?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
<?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
<?php
echo date(“M-d-Y”, mktime(0, 0, 0, 12, 32, 2007));
?>
Output
Jan-01-2008
It return current Unix timestamp with microseconds
Example
<?php
echo microtime();
?>
Output
microtime
<?php
echo “<pre>”;
$localtime = localtime();
print_r($localtime);
?>
Output
Array
(
[0] => 10
[1] => 23
[2] => 12
[3] => 25
[4] => 3
[5] => 112
[6] => 3
[7] => 115
[8] => 0
<?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
<?php
echo “May 17, 1984 is on a ” . date(“l”, gmmktime(0, 0, 0, 7, 1, 2007));
?>
Output
May 17, 1984 is on a Sunday
<?php
echo “<pre>”;
print_r(gettimeofday());
echo gettimeofday(true);
?>
Output
Array
(
[sec] => 1335335004
[usec] => 767981
[minuteswest] => -330
[dsttime] => 0
)
1335335004.7681
<?php
$date = date_create(‘2000-01-01’, timezone_open(‘Asia/Calcutta’));
echo date_format($date, ‘Y-m-d H:i:sP’) . “<br />”;
date_timezone_set($date, timezone_open(‘Australia/Perth’));
echo date_format($date, ‘Y-m-d H:i:sP’) ;
?>
Output
2000-01-01 00:00:00+05:30
2000-01-01 02:30:00+08:00
<?php
$date1 = new DateTime(‘2000-01-01’, new DateTimeZone(‘Asia/Calcutta’));
echo $date1->format(‘Y-m-d H:i:sP’) . “<br />”;
$date1->setTimezone(new DateTimeZone(‘Australia/Perth’));
echo $date1->format(‘Y-m-d H:i:sP’) ;
?>
Output
2000-01-01 00:00:00+05:30
2000-01-01 02:30:00+08:00
<?php
$date1 = date_create(null, timezone_open(‘Asia/Calcutta’));
$timezone = date_timezone_get($date1);
echo timezone_name_get($timezone);
?>
Output
Asia/Calcutta