|
Posted by phforum on 12/17/11 11:52
Thanks Andy
Simply and it's works
Andy Jeffries 寫道:
> On Sun, 09 Jul 2006 02:05:51 -0700, phforum wrote:
> > If user input the date is 2006-07-01. How to convert it to last year
> > 2005-07-01?
>
> The simplest way is as follows:
>
> $date_user_entered = strtotime($_POST["date"]);
> $date_one_year_ago = strtotime("-1 year", $date_user_entered);
>
> This also works perfectly with leap years which some other solutions may
> not.
>
> Cheers,
>
>
> Andy
>
> --
> Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
> http://www.gphpedit.org | PHP editor for Gnome 2
> http://www.andyjeffries.co.uk | Personal site and photos
Navigation:
[Reply to this message]
|