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 Andy Jeffries on 12/17/60 11:52

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]


Удаленная работа для программистов  •  Как заработать на 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

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