<?php
echo strtotime(“17 May 1984”);
?>
Output
453580200
<?php
echo strtotime(“17 May 1984”);
?>
Output
453580200
<?php
echo “<pre>”;
$format = ‘%d/%m/%Y %H:%M:%S’;
$strftime = strftime($format);
echo $strftime.”<br />”;
print_r(strptime($strf, $format));
?>
Output
25/04/2012 12:52:25
<?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
$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
<?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
Example
<?php
echo date(“M d Y H:i:s”, mktime(0, 0, 0, 1, 1, 2007)).”<br />”;
echo gmdate(“M d Y H:i:s”, mktime(0, 0, 0, 1, 1, 2007));
?>
Output
Jan 01 2007 00:00:00
Dec 31 2006 18:30:00