Several functions of processing time in Perl _perl

Source: Internet
Author: User
Tags local time sprintf

1, Time function: Returns the cumulative number of seconds from January 1, 1970
Use: My $t =time ();

2. localtime function: Get local time zone
Use: My $t =localtime (Time ());

3. gmtime function: Get GMT
Use: My $t =gmtime (Time ());

Get the format time (take the localtime function for example):
My ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $ISDST) = LocalTime (Time ());
The top three in the top form are the seconds, minutes, and times, the middle three is the number of days, the number of months (starting from 0), the year (relative to 1990), and the last three are the days of the week (weeks), the first days of the year, and daylight saving time.

To format the time by sprintf:

My $format _time=sprintf ("%d-%d-%d%d:%d:%d", $year +1990, $mon +1, $mday, $hour, $min, $sec);
Get shape such as: 2010-8-30-21:00:00 format of the time.
In addition, you can use the Perl date module to get the formatting time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.