There are several time processing functions in Perl:
1,Time Function: Returns the cumulative number of seconds from January 1, January 1, 1970.
Use: My $ t = time ();
2,Localtime Function: Get the local time zone
Use: My $ T = localtime (Time ());
3,Gmtime function:Obtain Greenwich Mean Time
Use: My $ T = gmtime (Time ());
Get the formatting time (taking the localtime function as an example ):
My ($ sec, $ min, $ hour, $ mday, $ Mon, $ year, $ wday, $ yday, $ isdst) = localtime (Time ());
The first three representations in the above formulaSeconds, minutes, and hours, The three in the middle areNumber of days, number of months (counted from 0), Year (relative to January 1, 1990 ),The last three areThe day of the week (the day of the week), the day of the year, and the time of renewal.
Use sprintf to format the time, for example:
My $ format_time = sprintf ("% d-% d: % d", $ year + 1990, $ mon + 1, $ mday, $ hour, $ min, $ Sec );
The preceding figure shows the time in the format of 21:00:00.
Of course, there are more than one method. You can also use the date module of Perl to get the formatting time.