Re: mon question/problem?
| From: | Peter Beckman | Date: | Wed, 16 Apr 2003 19:01:13 +0000 |
| Subject: | Re: mon question/problem? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27125@lists.php.net to get a copy of this message | ||
Use printf("%4d-%02d-%02d",$x['year']...etc) instead of your print line.
I believe %02d prints an integer padded with 0's. I could be wrong, but
that's close.
On Wed, 16 Apr 2003 Khristopher_Klaich@nywd.uscourts.gov wrote:
> Hello I have the below code that creates a drop down box which lists
> business days in the future. If I echo out the $form_date variable I get
> 2003-17-4 which from what I can tell is how it should work. I then have
> a date field in a mysql database that I am trying to insert this variable
> in and it is not working and I am guessing it is because that the 4 does
> not have a leading 0???? Can anyone give me an idea how to modify my code
> to make it have the leading 0 or tell me what is wrong with the code
> below? -Thanks-Khris
>
> $x=getdate();
> print "<select name=\"form_date\" id=\"form_date\">";
> for($i=1;$i<=170;$i++)
> {
> $x=getdate(mktime(0,0,0,$x['mon'],$x['mday']+1,$x['year']));
> if (($x['wday'] != 0) && ($x['wday'] != 6))
> print "<option
>
> value=".$x['year']."-".$x['mday']."-".$x['mon'].">".date("F
> d,Y",mktime(0,0,0,$x['mon'],$x['mday']-1,$x['year']));
> }
> print "</select>";
---------------------------------------------------------------------------
Peter Beckman Internet Guy
beckman@purplecow.com http://www.purplecow.com/
---------------------------------------------------------------------------