John Congdon


04 Jun, 2008

Calculating This Day Last Year in PHP

Posted by: John Congdon In: PHP Snippets

Have you ever wanted to know what the date was last year on this day?

Example: You want to compare sales from Wednesday of this year to the same Wednesday of last year. There is a very simple solution in PHP.

[code]
function ThisDateLastYear($date_in) {
// date_in = input date in form of YYYY-MM-DD
$days = 364;
return date('Y-m-d', strtotime("-364 days", mktime(0,0,0,$m,$d,$y)));
}
[/code]

Tags:

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

No Responses to "Calculating This Day Last Year in PHP"

Comment Form

About

I am a web programmer that specialized in E-Commerce, SEO, and Warehousing.

I currently work for bowlingball.com as the lead programmer. I am constantly working to make this website the premier website in the bowling industry, with a much bigger vision for the future.

Popular coupons powered by RetailMeNot.com