date ("m") question

Hello,

just one small question concerning 'previous month':

the function date ("m") gives me the current month.

So, date("m")-1 returns the previous month.

But, if the current month is "01", will this return "12" or "00" ?

Tx,
Ivan.


--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
ivan [ Mi, 24 Mai 2006 11:55 ] [ ID #1331143 ]

Re: date ("m") question

It will give 0
Sandy [ Mi, 24 Mai 2006 11:59 ] [ ID #1331144 ]

Re: date ("m") question

ivan wrote:
>
> just one small question concerning 'previous month':
>
> the function date ("m") gives me the current month.
>
> So, date("m")-1 returns the previous month.
>
> But, if the current month is "01", will this return "12" or "00" ?

0. If you want the previous month, you need to use something like
this:

date('m', strtotime ('-1 month'));

Cheers,
NC
nc [ Do, 25 Mai 2006 01:22 ] [ ID #1331155 ]

Re: date ("m") question

ivan wrote:
> Hello,
>
> just one small question concerning 'previous month':
>
> the function date ("m") gives me the current month.
>
> So, date("m")-1 returns the previous month.
>
> But, if the current month is "01", will this return "12" or "00" ?


1. If you want to post to several newsgroups, crosspost, don't multipost.
2. Answered in alt.php
3. If you're going to perform calculations with it, your string will be cast
to an integer, so you might as wel use date("n").

Grtz,
--
Rik Wasmus
Rik [ Mi, 24 Mai 2006 13:39 ] [ ID #1331164 ]
PHP » alt.php.sql » date ("m") question

Vorheriges Thema: poligon
Nächstes Thema: query efficiency