1. Time Function: returns the number of seconds that have elapsed since 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: Get 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 ());
In the preceding formula, the first three represent seconds, minutes, and hours. The three are days, months (counted from 0), and years (compared to January 1, 1990 ), the last three are valid IDs for the day of the week (the day of the week), day of the year, and hour.
Use sprintf to format the time:
My $ format_time = sprintf ("% d-% d: % d", $ year + 1990, $ mon + 1, $ mday, $ hour, $ min, $ Sec );
The time format is as follows: 21:00:00.
In addition, you can use the date module of Perl to obtain the formatting time.