From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Time functions - Perl Tutorial
From the course: Perl 5 Essential Training
Time functions
- [Voiceover] Perl comes with a standard set of time functions, which inherit their properties from the underlying C standard library. Here's a working copy of time.pl, from chapter 13 of the exercise files. I'll go ahead and I'll run this and you can see the output. That first output is from this time() call, and so it's assigning time() to $t. The time() function returns an integer value, which is the number of seconds since January 1st, 1970. And this is, of course, inherited from the underlying C standard library, which is based on Unix, and so this is based the Unix epoch. This is really excellent for doing time on math, so, for example here, if I wanted to add four years to this, right? I would say, $t += , and let's see, 60 seconds times 60 minutes times 24 hours times 365 days, and I know there's probably a leap year in there, and so I'm gonna say times 4 years and plus 1, and actually that is, that's gonna be plus one second, not plus one day, and so I'm gonna want this here,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.