Exercises, examples and other material relating to training module P216. This topic is presented on public course Perl bootcamp
Was 8 p.m. on 28th February in Los Angeles before or after 8 a.m. in Tokyo on 1st March? Perl has a very neat trick to handling dates and times, meaning that such questions can be easily resolved. We'll show you that trick, and we'll show you the various functions that you can use to handle dates and times in Perl.
|Articles and tips on this subject||updated|
|239||What and why for the epoch|
The Epoch occurred on 1st January 1970 ... at midnight, at the start of the day, GMT. It's an important concept in many programming languages, which work with times and dates before and after the epoch - it means that you can compare dates and times easily, even where month ends and different timezones ...
|765||Perl - turning seconds into days, hours, minutes and seconds|
So often you'll be working within a program in seconds - elapsed times, delays, that sort of thing - but want to report times back to the user in terms of hours, minutes and seconds. The conventional programming way to do this is to do a series of divisions and grab the remainder, but in Perl you can ...
|454||Time conversions in Perl|
Time isn't the easiest unit on which to do arithmetic, and dates expressed as a human-readable string are quite tricky to sort. Just imagine trying to write a program to work out whether 9 p.m. Pacific time on 28th Feb was before or after 3 a.m. in the UK on 1st March. And did you realise that, sorted ...
Examples from our training material
|chivvy|| Using %SIG to timeout keyboard entry|
|dante|| Date and time demos|
|dt1|| file last modified (days ago)|
|dt2|| dt2 - file last modified (seconds from 1.1.1970)|
|dt3|| current date and time (system dependent!)|
|dt4|| use of time and localtime|
|dt5|| compare a stated date and time with now!|
|hf|| Modified "chivvy" - perhaps less OS dependent|
|sigint|| Use of Signals in Perl to trap ^C (Control C)|
|tim|| Converting times between epoch seconds and regular time|
PicturesPerl - a modern language for ancient languages
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
File status operators and stat.
time, $^T, utime and other sources of time data.
Conversion to epoch seconds.
Conversion from epoch seconds.
Time calculations and elapsed time.
Year 2000 and year 2038 compliance.
Sleep and the alarm signal.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.