- Perl Basics
- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl Advanced
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Useful Resources
- Perl - Discussion
Perl time Function
Description
This function 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.
Syntax
Following is the simple syntax for this function −
time
Return Value
This function returns integer, seconds since epoch.
Example
Following is the example code showing its basic usage −
#!/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";
When above code is executed, it produces the following result −
Return time is 1176831539 Local time = Tue Apr 17 17:38:59 2007 Formated time = 17/4/2007 17:38:59 Tue
perl_function_references.htm
Advertisements