mkosmosports Posted September 29, 2006 Share Posted September 29, 2006 Hey all,Im working on a soccer site and I want php to dynamically produce the current year as part of a URL variable when they look at data from a specific season. Easy enough right: $thisyear=date('Y'); echo("<li><a href=\"leaguehome.html?group=1&season=$thisyear\">Premiership</a></li>The problem is, because a soccer season lies over two years, when 2007 rolls around and the season variable will equal 2007, the mysql query would try to get data from the 2007 season, which isnt there yet. I would need a small php function which would for example tell 2006 to run from Aug. 2006 to July 2007 as opposed to Jan.2006 to Dec.2006, so that when the $thisyear variable stays at 2006 until July 2007 when it would change over to 2007.....I know I maybe be confusing to read (php beginner) but if someone understands what I mean, I would appreciate any help or advice...Thanks!mkosmosports Quote Link to comment Share on other sites More sharing options...
Orio Posted September 29, 2006 Share Posted September 29, 2006 Try:[code]<?php$eight_mon_ago=strtotime("-8 months");date("Y", $eight_mon_ago);?>[/code]Basicly get's the year of 8 months ago.Orio. Quote Link to comment Share on other sites More sharing options...
mkosmosports Posted September 29, 2006 Author Share Posted September 29, 2006 Hey Orio,Thanks for the response...Using your below code I now have <?php $newseason=strtotime("+6 months"); date("Y", $newseason); echo("<li><a href=\"leaguehome.html?group=1&season=$newseason\">English Premiership</a></li> ?>However, the $newseason variable returns wild numbers like 1167347827, etc. Any ideas why? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.