note 48289 added to function.date
| From: | zavaboy | Date: | Fri, 17 Dec 2004 21:37:45 +0000 |
| Subject: | note 48289 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81945@lists.php.net to get a copy of this message | ||
Two different ways to get the week of the current month:
<?php
echo date('Y-m-d');
// 2004-12-12
$week1 = floor((date('d')-1)/7)+1; // 3
echo 'The '.date('jS').' is the '
.$week1.date('S',mktime(0,0,0,0,$week1,0)
.' '.date('l').' this month.';
// The 12th is the 2nd Sunday this month.
$week2 = floor((date('d')-1-date('w'))/7)+2; // 2
echo 'The '.date('jS').' is in the '
.$week2.date('S',mktime(0,0,0,0,$week2,0)
.' week this month.';
// The 12th is in the 3rd week this month.
?>
Enjoy!
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48289
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48289&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48289&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48289&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48289&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48289&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48289&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48289&report=yes
Search -- http://master.php.net/manage/user-notes.php