On Fri, 10 Oct 2003 12:13:45 -0400, Bill Akins wrote:
> Try this:
> #!/usr/bin/perl -w
>  
> my @now     = localtime;
> my $sec     = ( $now[0] );
> my $min     = ( $now[1] );
> my $hr      = ( $now[2] );
> my $day     = ( $now[3] );
> my $mth     = ( $now[4] + 1 );
> my $yr      = ( $now[5] + 1900 );
>  
> $day = ($day -1);

No!  Do _not_ try this!  What happens when you're using this code on the
1st of a month?

I recently fallen in love (...) with Time::Piece (and Time::Seconds),
which let me do this in a nifty way;

  #!/usr/bin/perl
  #
  use strict;
  use warnings;
  use Time::Seconds;
  use Time::Piece;

  my $today     = localtime;
  my $yesterday = $today - ONE_DAY;
  my $tomorrow  = $today + ONE_DAY;

Install Time::Piece and do a 'perldoc Time::Piece' for more information.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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

Reply via email to