You are here: Re: How to convert current date to last year date? « PHP Programming Language « IT news, forums, messages
Re: How to convert current date to last year date?

Posted by Chung Leong on 10/07/41 11:52

Andy Jeffries wrote:
> 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,

In one line:

$date_one_year_ago = strtotime("{$_POST['date']} -1 year",
$date_user_entered);

 

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

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