Tag Archives: Date

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

gmdate

Its similar to date function but formats GMT.

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

getdate

It returns date/time details

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
)

date

It can be used to format the date/time of the server .

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