You can do it using localtime and printf or POSIX::strftime. POSIX is a core module. FYI POSIX::mktime converts sec,min,hr,d,m,y to epoch time if you want to go the other way.

my $time = time(); my ($sec,$min,$hour,$day,$mon,$year) = localtime($time); $year+= 1900; $mon += 1; $year = substr $year, 1; printf "%02d/%02d/%02d %02d:%02d\n", $year, $mon, $day, $hour, $min; use POSIX qw(strftime); print strftime("%y/%m/%d %H:%M\n", localtime); print strftime(" POSIX strftime a %a A %A b %b B %B c %c d %d H %H I %I j %j m %m M %M p %p S %S U %U w %w W %W x %x X %X y %y Y %Y Z %Z ", localtime); __DATA__ 08/03/16 11:37 08/03/16 11:37 POSIX strftime a Sun A Sunday b Mar B March c 3/16/2008 11:37:48 AM d 16 H 11 I 11 j 076 m 03 M 37 p AM S 48 U 11 w 0 W 10 x 3/16/2008 X 11:37:48 AM y 08 Y 2008 Z Vulcan Standard Time

In reply to Re: seconds since the epoch by tachyon-II
in thread seconds since the epoch by my_nihilist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.