note 89184 added to function.strtotime
| From: | bbutts at stormcode dot net | Date: | Wed, 25 Feb 2009 18:43:12 +0000 |
| Subject: | note 89184 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-151127@lists.php.net to get a copy of this message | ||
After looking around I couldn't find any code that would properly and simply compute the last
day of the month. +1 month will not work ex. 1 month after February 28th is March 3rd.
This line of code returns the last day of the current month:
echo 'Last day of the month: ' . date('m/d/y h:i a',(strtotime('next
month',strtotime(date('m/01/y'))) - 1));
It uses the first of the current month, gets the first of the next month, then subtracts 1 second to
give you 11:59pm on the last day of the current month.
Hope this helps someone.
----
Server IP: 209.41.74.194
Probable Submitter: 74.92.46.190
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/89184
Del: integrated -- https://master.php.net/note/delete/89184/integrated
Del: useless -- https://master.php.net/note/delete/89184/useless
Del: bad code -- https://master.php.net/note/delete/89184/bad+code
Del: spam -- https://master.php.net/note/delete/89184/spam
Del: non-english -- https://master.php.net/note/delete/89184/non-english
Del: in docs -- https://master.php.net/note/delete/89184/in+docs
Del: other reasons-- https://master.php.net/note/delete/89184
Reject -- https://master.php.net/note/reject/89184
Search -- https://master.php.net/manage/user-notes.php