calculate week from date in php
date('w'); //gets day of week as number(0=sunday,1=monday...,6=sat)
//note:returns 0 through 6 but as string so to check if monday do this:
if(date('w') == 1){
echo "its monday baby";
}Things to be aware of when using week numbers with years.
<?php
echo date("YW", strtotime("2011-01-07")); // gives 201101
echo date("YW", strtotime("2011-12-31")); // gives 201152
echo date("YW", strtotime("2011-01-01")); // gives 201152 too
?>
BUT
<?php
echo date("oW", strtotime("2011-01-07")); // gives 201101
echo date("oW", strtotime("2011-12-31")); // gives 201152
echo date("oW", strtotime("2011-01-01")); // gives 201052 (Year is different than previous example)
?>
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.
Also in PHP:
- The key "initial" is not recognized and ignored.
- "Allowed memory size of 134217728 bytes exhausted (tried to allocate 56627200 bytes)" in wamp
- find char in string php
- date i php
- array foreach phph
- cache set in laravel
- PHP redireczt
- count rows mysql limit php
- date('c') php
- delete all laravel cache
- clear laravel cache
- explain email injection
- clear cache laravel web
- Allowed memory size of 1610612736 bytes exhausted (tried
- check if a string contains php
- exist in string php
- display data from two dimensional array in vew laravel
- \r in php
- database seeding in laravel
- contain in string php
- composer-php version check
- encrypt api token laravel
- Allowed memory size of 2147483648 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/composer/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
- convert upper case php