An if/else with the same code is pointless. Why not use use the same statement all the time? The %02d won't do anything if both digit places are filled. Printing "5" with %02d comes out 05, printing 25 with %02d comes out 25. What's the point?
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 08, 2001 9:51 AM > To: [EMAIL PROTECTED] > Subject: Re: Problem with IF statement > > > > Just add teh sprintf to the else block too. > > else > { > $year = sprintf("%02d",$now[5] % 100); > } > > -- Rex > > -----Original Message----- > From: Glenn Cannon [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 08, 2001 10:47 AM > To: [EMAIL PROTECTED] > Subject: Problem with IF statement > > > I am trying to force the current year to be show as a two digit > number, with > leading zero if necessary. > Here is what I am using currently, what am I doing wrong? > > #Code On > > @now = localtime; > if (length($now[5] % 100) == l) > { > $year = sprintf("%02d", $now[5] % 100) > } > else > { > $year = $now[5] % 100 > } > > #Code Off > > Glenn Cannon > [EMAIL PROTECTED] > Level II Certified DCI Judge > 'There is no spoon.' > www.eventsbeyondbelief.com > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]