[thelist] php date

Seb seb at members.evolt.org
Sat Dec 29 20:16:58 CST 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


>John Corry wants to know:
> > http://www.sugarbeachresort.net/index.php?page=rates
> >
> > This is really a question of 'logical approach' more than anything.
> >
> > At the URL above I have a table for condo rates. I'm about to build a db
> > driven site that has this information for about 10-20 properties and need
>to
> > automate part of it. I've got the actual rates coming from the db already,
> > that's a given. It's the date ranges that has me stumped because I don't
> > want to store that value, I want to generate it based on the current date.
> >
> > The 'high season' and 'low season' dates change every year. I need to
> > automate that change.
> >
> > Hm, if this it too complicated though I guess it would be fine and easy
> > enough to just put the dates in an include and use that file for all of
>the
> > sites...but, if there's some great PHP date magic one of you could
>enlighten
> > me to, that'd be GREAT!


Piece of cake.

Create a table SEASONS with the following columns:

Season_display_start (datetime)
Season_display_end (datetime)
High_season_start (datetime)
High_season_end (datetime)
Low_season_start (datetime)
Low_season_end (datetime)

Then, populate with a record for every year that you want to. The 
season_display_start and season_display_end dates specify when to start and 
stop displaying the high and low season dates for that year. (So, you could 
display the high and low season dates for 2003 from 11th April 2002 to 19th 
May 2003.)

Your logic will be:

$sql_query = "select * from SEASONS where season_display_start < " . 
$current_date . " and season_display_end > " . $current_date ;

Ta da!

Seb.


-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPC55OPTbQoqHwhmzEQINJgCfQ/CmX76FgYuw918pYnDGuzepHvQAn2K9
T33zucTJlGWSn/EJmEbDNw2K
=zWHV
-----END PGP SIGNATURE-----





More information about the thelist mailing list