In scalar context it returns a formatted date string:
In list context, it returns an array of nine values defining the date and time (lookup the documentation to find out what they are):$ perl -e 'my $timestamp = localtime time; print "$timestamp\n"' Fri Jul 27 21:08:16 2018
The first three fields say that I ran the command at 21:08:23 (local time), and the following 3 ones represent the date, etc. (but the date requires some calculations: 6 stands for July, because January is 0, and you need to add 1900 to 118 to get the year).$ perl -e 'my @timefields = localtime time; print join " ", @timefiel +ds;' 23 8 21 27 6 118 5 207 1
So you can do your own calculations as needed, but it is often better to use modules such as Time::Piece already suggested by hippo or some other modules (there are many of them).
In reply to Re: Converting multiple unix timestamps
by Laurent_R
in thread Converting multiple unix timestamps
by Maire
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |