Jump to content


Photo

Setting a different start and end date to a year....


  • Please log in to reply
2 replies to this topic

#1 mkosmosports

mkosmosports
  • Members
  • PipPipPip
  • Advanced Member
  • 196 posts

Posted 29 September 2006 - 08:18 PM

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

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 29 September 2006 - 08:24 PM

Try:

<?php

$eight_mon_ago=strtotime("-8 months");
date("Y", $eight_mon_ago);

?>

Basicly get's the year of 8 months ago.

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 mkosmosports

mkosmosports
  • Members
  • PipPipPip
  • Advanced Member
  • 196 posts

Posted 29 September 2006 - 10:21 PM

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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users