Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to print the number of seconds since epoch.

time(), localtime() don't put it in that format.

What function gives you epoch seconds?

Replies are listed 'Best First'.
Re: Need to print Epoch Seconds!!!
by monkfan (Curate) on May 10, 2005 at 03:15 UTC
    Perl Cookbook Chapter 3.2.
    Use the timelocal or timegm functions in the standard Time::Local module, depending on whether the date and time is in the current time zone or in UTC.
    use Time::Local; $TIME = timelocal($sec, $min, $hours, $mday, $mon, $year); $TIME = timegm($sec, $min, $hours, $mday, $mon, $year);
    Regards,
    Edward
Re: Need to print Epoch Seconds!!!
by jdporter (Paladin) on May 10, 2005 at 03:13 UTC
    time() gives you that integer, but only if you call it in scalar context. RTFM.

    Updated. jdporter admonishes himself to RTFM.

      Context, schmontext; time returns the same thing.

      $ perl -le 'my( $l ) = time; my $s = time; print join( "\n", $l, $s )' 1115694879 1115694879
    A reply falls below the community's threshold of quality. You may see it by logging in.