Syntax
Definition and Usage
Returns a list of values corresponding to the date and time as specified by EXPR, or
date and time returned by the time function if EXPR is omitted, localized for the
standard Greenwich mean time. The values returned are as follows:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
All list elements are numeric, and come straight out of the C `struct tm'. $sec, $min, and $hour are the seconds, minutes, and hours of the specified time. $mday is the day of the month, and $mon is the month itself, in the range 0..11 with 0 indicating January and 11 indicating December. $year is the number of years since 1900. That is, $year is 123 in year 2023. $wday is the day of the week, with 0 indicating Sunday and 3 indicating Wednesday. $yday is the day of the year, in the range 0..364 (or 0..365 in leap years). $isdst is always 0 .
Return Value
In scalar context a string of the form: Thu Sep 21 14:52:52 2000
In list context the individual time component
values (seconds, minutes, hours, day of
month, month, year, day of week, day of
year, daylight savings time).
Example
Try out following example:
#!/usr/bin/perl
@weekday = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
$local_time = gmtime();
print "Local time = $local_time\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
$year = $year + 1900;
print "Formated time = $mday/$mon/$year $hour:$min:$sec $weekday[$wday]\n";
|
|