note 108885 added to function.strtotime
| From: | comp at compbcn dot es | Date: | Fri, 01 Jun 2012 06:58:00 +0000 |
| Subject: | note 108885 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188354@lists.php.net to get a copy of this message | ||
to get previous month
<?php
$t = strtotime('-1 month');
echo strftime('%B', $t);
?>
but it not work, if u need to get month when in this year we have to do it for 31 of may. Cos it
will be 1 may...
we can do somthing like this:
<?php
$months =
array(1=>'ЯнваÑÑ','ФевÑалÑ','ÐаÑÑ'...);
echo $months[date('m')-1];
?>
but... below is a better solution:
<?php
$t = strtotime('first day of previous month');
echo strftime('%B', $t);
?>
source from habrahabr.ru
----
Server IP: 93.93.89.7
Probable Submitter: 81.184.47.6
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/108885
Del: integrated -- https://master.php.net/note/delete/108885/integrated
Del: useless -- https://master.php.net/note/delete/108885/useless
Del: bad code -- https://master.php.net/note/delete/108885/bad+code
Del: spam -- https://master.php.net/note/delete/108885/spam
Del: non-english -- https://master.php.net/note/delete/108885/non-english
Del: in docs -- https://master.php.net/note/delete/108885/in+docs
Del: other reasons-- https://master.php.net/note/delete/108885
Reject -- https://master.php.net/note/reject/108885
Search -- https://master.php.net/manage/user-notes.php