in reply to Converting multiple unix timestamps

Your use of the localtime function was a good idea, except that you would need to use it in list context instead of scalar context.

In scalar context it returns a formatted date string:

$ perl -e 'my $timestamp = localtime time; print "$timestamp\n"' Fri Jul 27 21:08:16 2018
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 @timefields = localtime time; print join " ", @timefiel +ds;' 23 8 21 27 6 118 5 207 1
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).

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).

Replies are listed 'Best First'.
Re^2: Converting multiple unix timestamps
by Maire (Scribe) on Aug 02, 2018 at 09:33 UTC
    Ah, thank you. That makes a lot of sense, thanks again!