A Taylor wrote:
> 
> Hi all,

Hello,

> 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 ????

Yes, use sprintf.

my $hour  = sprintf '%02d', (gmtime)[2];
my $min   = sprintf '%02d', (gmtime)[1];
etc...


> 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 ^_^

They are probably using a different time zone then you.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to