starface245 has asked for the wisdom of the Perl Monks concerning the following question:

I know there a one-line for unix timestamp convert to human timestamp. Is there one-line for Mac timestamp convert to human timestamp?

Replies are listed 'Best First'.
Re: Mac timestamp
by karlgoethebier (Abbot) on Dec 10, 2013 at 19:06 UTC
    perl -MPOSIX -e 'print strftime("%Y-%m-%d %H:%M:%S", localtime(qx(date + +%s)));'

    ..or a variation of this...

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Re: Mac timestamp
by Laurent_R (Canon) on Dec 10, 2013 at 22:03 UTC
    I don't have a Mac and therefore cannot test, but if you are using Perl's internal date functions, you should not have to worry about whether you are under Unix, Mac, Windows or whatever, Perl will manage it for you.
Re: Mac timestamp
by kcott (Archbishop) on Dec 11, 2013 at 17:44 UTC

    G'day starface245,

    The following examples are run on a Mac.

    The localtime function may be sufficient for your needs:

    $ perl -le 'print scalar localtime' Thu Dec 12 04:41:39 2013

    For formatted dates, take a look at Time::Piece. Here's what the default format produces:

    $ perl -MTime::Piece -le 'print localtime->strftime' Thu, 12 Dec 2013 04:42:06 EST

    -- Ken