Web | This Site

Perl Home
PERL Functions
© 2011 TutorialsPoint.COM

| Home |  | References |  | About TP |  | Advertising

# PERL time Function

## Syntax

time

## Definition and Usage

Returns the number of seconds since the epoch (00:00:00 UTC, January 1, 1970, for most systems; 00:00:00, January 1, 1904, for Mac OS). Suitable for feeding to gmtime and localtime.

## Return Value

- Integer, seconds since epoch

## Example

    #!/usr/bin/perl -w

    @weekday = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");

    $retval = time();

    print "Return time is $retval\n";
    $local_time = gmtime( $retval);

    print "Local time = $local_time\n";
    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
    $year = $year + 1900;
    $mon += 1;
    print "Formated time = $mday/$mon/$year $hour:$min:$sec $weekday[$wday]\n";

It will produce following results:

    Return time is 1176831539
    Local time = Tue Apr 17 17:38:59 2007
    Formated time = 17/4/2007 17:38:59 Tue

Advertisement

Online Image Processing

Indian Baby Names