[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Another time question



At 10:22 pm +0000 6/1/00, Lasar Liepins wrote:

>How can I output the current date or time as day.month.year and
>hour.minute ?


Using just the same routine I posted a little while ago:

        #!perl -w
        ### day.month.year and hour.minute
        use strict;
        my ( @time, $timestamp, $save) = (localtime time);
        my ( $mday, $mon, $year, $hour, $min) = @time[3,4,5,2,1];
        $year = $year + 1900;
        #$year = substr $year, 2; ### remove century
        $timestamp =  sprintf qq(%02u.%02u.%02u %02u.%02u),
             $mday, $mon + 1, $year,  $hour, $min;
        $_ = MacPerl::Answer
           ("\n$timestamp","OK", "Cancel");


or


        #!perl -w
        use strict;
        my @time = localtime time;
        $time[5] = $time[5] + 1900;
        $time[4] = $time[4] + 1;
        MacPerl::Answer (sprintf qq(\n%u.%u.%u %02u.%02u),
          @time[3,4,5,2,1]);

JD


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org