php date tag code example
Example 1: php get day from date
$timestamp = strtotime('2009-10-22');
$day = date('D', $timestamp);
var_dump($day);
Example 2: date in php
Things to be aware of when using week numbers with years.
<?php
echo date("YW", strtotime("2011-01-07"));
echo date("YW", strtotime("2011-12-31"));
echo date("YW", strtotime("2011-01-01"));
?>
BUT
<?php
echo date("oW", strtotime("2011-01-07"));
echo date("oW", strtotime("2011-12-31"));
echo date("oW", strtotime("2011-01-01"));
?>
Reason:
Y is year from the date
o is ISO-8601 year number
W is ISO-8601 week number of year
Conclusion:
if using 'W' for the week number use 'o' for the year.