Date - drop down menu

Hi,

I would like to use date() function show in the drop down menu start
from today to next 1 Month.

So it will be something like this.

4/3/2008
4/4/2008
4/5/2008
.......
5/12008
5/2/2008
5/3/2008

Any idea? thanks
Slickuser [ Fr, 04 April 2008 21:55 ] [ ID #1935706 ]

Re: Date - drop down menu

*** Slickuser escribió/wrote (Fri, 4 Apr 2008 12:55:12 -0700 (PDT)):
> I would like to use date() function show in the drop down menu start
> from today to next 1 Month.
>
> So it will be something like this.
>
> 4/3/2008
> 4/4/2008
> 4/5/2008
> ......
> 5/12008
> 5/2/2008
> 5/3/2008

Not fully tested but it should work:

<?php

$now = time();
$next_month = strtotime('+1 month', $now);

for($i=$now; $i<$next_month; $i=strtotime('+1 day', $i)){
echo date('Y-m-d', $i) . "\n";
}

?>

Adjust the format of the echo line to your liking.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
webmasterNOSPAMTHANKS [ Fr, 04 April 2008 22:26 ] [ ID #1935708 ]

Re: Date - drop down menu

<comp.lang.php>
<Slickuser>
<Fri, 4 Apr 2008 12:55:12 -0700 (PDT)>
<69a9f1a9-2995-4c84-a7aa-cab802a29c35 [at] q10g2000prf.googlegroups.com>

> I would like to use date() function show in the drop down menu start
> from today to next 1 Month.
>
> So it will be something like this.
>
> 4/3/2008
> 4/4/2008
> 4/5/2008
> ......
> 5/12008
> 5/2/2008
> 5/3/2008
>

$rambo=1; $nuke=0;
while ($rambo<31)
{
$kill[$rambo]=date("D dS M",time()+$nuke);
$nuke=$nuke+386400;
$rambo=$rambo+1;
}

Untested - but something like this will generate 31 dates .


--
www.krustov.co.uk
Hans-Peter Sauer [ Fr, 04 April 2008 22:29 ] [ ID #1935709 ]

Re: Date - drop down menu

*** Krustov escribió/wrote (Fri, 4 Apr 2008 21:29:58 +0100):
> $rambo=1; $nuke=0;
> while ($rambo<31)
> {
> $kill[$rambo]=date("D dS M",time()+$nuke);
....

Wow! It's the first script I find that's rated "adults only" for violent
content xD


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
webmasterNOSPAMTHANKS [ Fr, 04 April 2008 22:53 ] [ ID #1935710 ]

Re: Date - drop down menu

Slickuser wrote:
> Hi,
>
> I would like to use date() function show in the drop down menu start
> from today to next 1 Month.
>
> So it will be something like this.
>
> 4/3/2008
> 4/4/2008
> 4/5/2008
> ......
> 5/12008
> 5/2/2008
> 5/3/2008
>
> Any idea? thanks
>

Several ways to do it, but how about:

for ($i = 0; $i = 30; $i++)
echo "date('m/d/Y',strtotime("now + $i days"));

Add your html as necessary.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex [at] attglobal.net
==================
Jerry Stuckle [ Fr, 04 April 2008 23:59 ] [ ID #1935712 ]

Re: Date - drop down menu

Slickuser wrote:
> Hi,
>
> I would like to use date() function show in the drop down menu start
> from today to next 1 Month.
>
> So it will be something like this.
>
> 4/3/2008
> 4/4/2008
> 4/5/2008
> ......
> 5/12008
> 5/2/2008
> 5/3/2008
>
> Any idea? thanks

How about use some javascript gadgets?
http://marcgrabanski.com/code/ui-datepicker/

--
Xu, Qian (stanleyxu)
nospam [ So, 06 April 2008 15:48 ] [ ID #1936630 ]

Re: Date - drop down menu

nospam wrote:
> Slickuser wrote:
>> Hi,
>>
>> I would like to use date() function show in the drop down menu start
>> from today to next 1 Month.
>>
>> So it will be something like this.
>>
>> 4/3/2008
>> 4/4/2008
>> 4/5/2008
>> ......
>> 5/12008
>> 5/2/2008
>> 5/3/2008
>>
>> Any idea? thanks
>
> How about use some javascript gadgets?
> http://marcgrabanski.com/code/ui-datepicker/
>

Why? PHP does it quite well - and doesn't require JS to be enabled on
the browser.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex [at] attglobal.net
==================
Jerry Stuckle [ So, 06 April 2008 17:14 ] [ ID #1936632 ]
PHP » comp.lang.php » Date - drop down menu

Vorheriges Thema: Re: Problem with a contact me php form. Anyone look please?
Nächstes Thema: Is there an API function thats me if the php interpreter is thread