You are here: Re: date("m") question « All PHP « IT news, forums, messages
Re: date("m") question

Posted by Rik on 09/28/05 11:48

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" ?

date() will make a string, which you cast to an integer (1) by subtracting
an integer. I am not capable of testing it right now, I suspect it will
return 0.

Try:
date("m',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
Which will first make a current timestamp, and return 12 if performed in
january

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация