<?php
echo date(“M-d-Y”, mktime(0, 0, 0, 12, 32, 2007));
?>
Output
Jan-01-2008
<?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
<?php
echo “<pre>”;
print_r(gettimeofday());
echo gettimeofday(true);
?>
Output
Array
(
[sec] => 1335335004
[usec] => 767981
[minuteswest] => -330
[dsttime] => 0
)
1335335004.7681
Example
<?php
echo “<pre>”;
$timeDetails = getdate();
print_r($timeDetails);
?>
Output
Array
(
[seconds] => 48
[minutes] => 49
[hours] => 11
[mday] => 25
[wday] => 3
[mon] => 4
[year] => 2012
[yday] => 115
[weekday] => Wednesday
[month] => April
[0] => 1335334788
)
Example
<?php
echo date(‘Y-m-d :h i’);
?>
Below given are the date formats
d,D,j,l,N,S,w,z,W,F,m,M,n,t,L,o,Y,y,a,A,B,g,G,h,H,i,s,u,e,I,O,P,T,Z,c,r,U
Output
2012-04-25 :11 43