Tag Archives: Date

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

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