$hour = 1; $hour = sprintf("%02d",$hour); // $hour now become "01" $hour = 10; $hour = sprintf("%02d",$hour); // $hour still "10"
no need for the checking it's length. david "A Taylor" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi all, > Thanks for your help so far - I have managed to sort out my time and date > problem but there are a few points that I dont understand. > The code I have used is as follows: > > # get the hours, mins, weekday, day, month and year > $hour = (gmtime)[2]; > $min = (gmtime)[1]; > $wday = (qw(Sun Mon Tue Wed Thu Fri Sat)) [(gmtime) [6]]; > $day = (gmtime)[3]; > $month = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)) [(gmtime) > [4]]; > $year = (gmtime)[5] + 1900; > > # test the length of $min - if length = 1 then add a '0' at the begining. > > $minlen = length $min; > if ($minlen < 2) > { > $min = "0".$min; > } > $hour ++; > > I have had to do a test to see if the $min var is 1 or 2 in length: > > $minlen = length $min; > if ($minlen < 2) > { > $min = "0".$min; > } > > this is because 22:07 (for example) would otherwise come out as 22:7 - which > is a bit confusing. Is there a better way to do this ???? > > Also I have had to add 1 to the hour var: $hour ++; even though my web space > providers are in the same country as me - does anyone know why this is - I > am probably being a bit daft - well it is 1am, and I have been perling for > about 16 hours now !!! Gulp ^_^ > > Thanks for any help > Anadi > > > You are just a dewdrop, and as you meditate the dewdrop starts slipping from > the petals of the Lotus towards the ocean. When the meditation is complete, > the dewdrop has disappeared into the ocean. Or you can say, the ocean has > disappeared into the dewdrop. > > Bhagwan Shree Rajneesh. > > > _________________________________________________________________ > MSN Photos is the easiest way to share and print your photos: > http://photos.msn.com/support/worldwide.aspx > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]