Page 138 - Open Soource Technologies 304.indd
P. 138
Unit 8: Working with Strings, Date and Time
Notes
Year, numeric four Y %Y
digits
Year, numeric %G This number might differ from
four digits; year the “real year’” as in ISO 8601;
component for January 1 might still belong to
%w week 53 of the year before. In that
case, the year returned with this
formatting option will be the one
of the previous year, too.
Day of week, full 1 %A For strftime (), the day is shown
textual according to the names of the
current locale.
<?php
setlocale (LC_ALL, ‘C’);
echo strftime (‘%A’);
setlocale (LC_ALL, ‘no_NO’);
echo strftime (‘%A’);
?>
shows
Monday Mandag
Day of week, w %W The range is 0-6 with 0 being
numeric Sunday and 6 being Saturday.
(0=Sunday)
Day of week, %u The range is 1-7 with I being
numeric Monday and 7 being Sunday.
(1=Monday)
Day of week, short D %a For the (gm) strftime ( ) function,
textual the name is shown according to
the locale; for (gm) date( ) it is the
normal three letter abbreviation:
Sun, Sat, Wed, and so on.
Day of year, %j The day number in a year, starting
numeric with with 001 for January 1 to 365 or
leading zeroes 366.
Day of year, z The day number in a year, starting
numeric without with 0 for January 1 to 365 or 365
leading zeroes
DST active I Returns 1 if DST is active and 0
if DST is not active for the given
timestamp.
Formatted, %D Gives the same result as using
%d/%m/%y %d/%m/%y.
Formatted, %T Gives the same result as using
%H:%M:%S &H;%M:%S.
Contd...
LOVELY PROFESSIONAL UNIVERSITY 133