Dave Adams wrote:
I can get date but not time.
use Time::localtime;
$tm = localtime;
printf("Current date: %04d-%02d-%02d\n",$tm->year+1900,($tm->mon)+1, $tm->mday);
printf("Current time: %02d:%02d:%02d\n",$tm->hours,$tm->min,$tm->sec);
Any help would be appreciated.
DA
Rather than using Tim
On 7/19/05, Dave Adams <[EMAIL PROTECTED]> wrote:
> You are right.
>
> I thought it was something more because I got an error:
>
> Can't locate object method "hours" via package "Time::tm" (perhaps you forgot
> to
> load "Time::tm"?) at ./GetDate.pl line 4.
>
> I was also using the Orielly Per
You are right.
I thought it was something more because I got an error:
Can't locate object method "hours" via package "Time::tm" (perhaps you forgot to
load "Time::tm"?) at ./GetDate.pl line 4.
I was also using the Orielly Perl CookBook 2nd Edition and it
specifies $hours and not $hour.
This
this is what i use to get date/time; something different that may be of benefit
use POSIX 'strftime';
sub timestamp
{
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime;
my $am_pm = $hour > 11 ? " PM" : " AM";
$year +
Dave Adams wrote:
> I can get date but not time.
>
> use Time::localtime;
> $tm = localtime;
> printf("Current date: %04d-%02d-%02d\n",$tm->year+1900,($tm->mon)+1,
> $tm->mday);
> printf("Current time: %02d:%02d:%02d\n",$tm->hours,$tm->min,$tm->sec);
The above should include $tm->hour instead of