note 108885 deleted from function.strtotime by danbrown
| From: | danbrown@php.net | Date: | Fri, 01 Jun 2012 15:27:47 +0000 |
| Subject: | note 108885 deleted from function.strtotime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-188360@lists.php.net to get a copy of this message | ||
Note Submitter: comp at compbcn dot es
----
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