Page 139 - Open Soource Technologies 304.indd
P. 139
Open Source Technologies
Notes
Formatted, in %R The time in 24-hour notation
24-hour notation withour seconds.
<?php
echo strftime (“%R\n”);//
shows
23:53
?>
Formatted, in am/ %r The time in 12-hour notation
p.m. notation including seconds.
<?php
echo strftime (“%r\n”);//
shows
11:53:47
?>
ISO 8601 Week Numbers: That the ISO 8601 year format option (%V) might
differ from the normal year format option (%Y) if a year has less than four days:
<?php
for ($i = 27; $i <= 31; $i++) {
echo gmstrftime(
“%Y-%m-%d (%V %G, %A)\n”,
gmmktime(0, 0, 0, 12, $i, 2004)
);
}
for ($i = 1; $i <= 6; $i++) {
echo gmstrftime(
“%Y-%m-%d (%V %G, %A)\n”,
gmmktime(0, 0, 0, 1, $i, 2005)
);
}
?>
The script outputs
2004-12-27 (53 2004, Monday)
2004-12-28 (53 2004, Tuesday)
2004-12-29 (53 2004, Wednesday) Contd...
134 LOVELY PROFESSIONAL UNIVERSITY