Toby Stuart <[EMAIL PROTECTED]> writes:

> Check the length of second, minute and hour.
> If the length == 1 then add a leading zero eg. $sec = "0" . $sec
> Maybe there is some other "magical" way of doing this, if there is i'm not
> aware of it :)

Good idea... thanks.



"John W. Krahn" <[EMAIL PROTECTED]> writes:

> printf " %02d/%02d/%04d %02d:%02d:%02d\n", $lta[4] + 1, $lta[3], $lta[5] + 1900, 
>@lta[2,1,0];

Thanks.. the tips work good.  And I overlooked the part about mnths
being 0-11.

I get the idea from your posted printf line and learned a new trick
with the @ar[2,4,7] syntax you used but couldn't really understand why it
gave a screwball year in my script until I noticed the `=' missing in
$lta[5] + 1900.

Still not sure I understand why it needs to be there.

cat test2

  #!/usr/local/bin/perl -w
  $now = time;
   
  $date_spec = ($now - 86400);
  # local time adjusted
  @lta = localtime($date_spec); 

  $mnth = ($lta[4] + 1);
  print " $mnth/$lta[3]/" . ($lta[5] += 1900) . " $lta[2]:$lta[1]:$lta[0]\n";
  print localtime() . "\n";
  printf " %02d/%02d/%04d %02d:%02d:%02d\n", $lta[4] + 1, $lta[3], $lta[5] + 1900, 
@lta[2,1,0];

OUTPUT:
  $ ./test2
   12/15/2002 20:16:38
  Mon Dec 16 20:16:38 2002
   12/15/3902 20:16:38



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

Reply via email to