in reply to How can I convert epoch seconds to date format

Use the strftime function from POSIX.pm.

use POSIX 'strftime'; my $date = strftime '%Y/%m/%d %H:%M:%S', localtime $epoch;

p.s. I corrected your illogical US date format to something more sensible :)

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: How can I convert epoch seconds to date format
by ikegami (Patriarch) on May 10, 2006 at 14:54 UTC
    Or you could use the user's time settings to decide the order of year, month and day:
    use POSIX 'strftime'; my $date = strftime '%c', localtime $epoch

      Some of the 'aggregate' specifiers don't work on all platforms (yes windows I'm loooking at you) unfortunately.

      /J\

        Maybe, but that particular one does work on Windows, at least in the ActiveState build. So do %x and %X. The order of the date/time components in the returned string when using those specifiers is dictated by the preferences set in "Regional Settings".
Re^2: How can I convert epoch seconds to date format
by Anonymous Monk on May 10, 2006 at 16:30 UTC
    Thanks a lot....