Jump to content

Archived

This topic is now archived and is closed to further replies.

mkosmosports

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.