Thank you both, I will try the code and go from there. Thank you again
Daniel Brown wrote:
Ben, make sure whatever method you use, you use the operator
combinations >= and <= as Richard just showed you. I had forgotten to
do that, which would mean (in my example) that the 13th of April and
13th of May of each year would not be counted, only 14 April through
12 May of any given year. Also, expanding on Richard's example, you
can make it dynamic per year by combining the strtorime() and date()
functions, so you wouldn't have to update your code annually.
However, this would only work if both dates were within the same
(current) year at the time the script was executed:
<?
$start_date = strtotime('4 August '.date("Y"));
$end_date = strtotime('9 October '.date("Y"));
$current = time();
if ($current >= $start_date && $current <= $end_date)
{
// Do whatever should only happen between the
// 4th of August and the 9th of October here
}
?>
On 4/30/07, *Richard Davey * <rich@xxxxxxxxxxxxx
<mailto:rich@xxxxxxxxxxxxx>> wrote:
Ben Clapp wrote:
> I am new to PHP programming and need some help. I have an image
that i
> have show up each May for the month with $mymonth = date("m",
mktime()),
> but i want to set up a date range for it to show up. Ex. 4-13 to
5-13
> each year. How can I do that? Any help would be great.
There are loads of ways, but hopefully as you're new to PHP this one
will be easy to follow and make sense:
$start_date = strtotime('4 August 2007');
$end_date = strtotime('9 October 2007');
$current = time();
if ($current >= $start_date && $current <= $end_date)
{
// Do whatever should only happen between the
// 4th of August and the 9th of October here
}
strtotime() is extremely powerful / useful, and well worth reading
about:
http://uk.php.net/manual/en/function.strtotime.php
Cheers,
Rich
--
Zend Certified Engineer
http://www.corephp.co.uk
"Never trust a computer you can't throw out of a window"
--
PHP General Mailing List ( http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php