Hello Adam Peterson, in a previous mail you wrote:

> hi i'm using date::calc and am wondering if there is a function to get
> system time in am/pm format. can any one help? i can get 24 hour time
> without a problem.
> 
> thanks,
> -adam

Date::Calc doesn't provide that directly, but it's very easy to do:

#!perl -w

use strict;
no strict "vars";

use Date::Calc qw(:all);

@date = Today_and_Now();

$ampm = 'AM';
if ($date[3] >= 12)
{
    $date[3] -= 12;
    $ampm = 'PM';
}

$date = sprintf(
    "%s %s %d %02d:%02d:%02d %s",
    Month_to_Text($date[1]),
    English_Ordinal($date[2]),
    $date[0],
    @date[3..5],
    $ampm);

print "$date\n";

__END__

Running this program produces:

:> perl ampm.pl
December 4th 2002 01:13:45 PM

Hope this helps!
-- 
    Steffen Beyer <[EMAIL PROTECTED]>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)

Reply via email to