Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Mac timestamp

by starface245 (Novice)
on Dec 10, 2013 at 17:42 UTC ( [id://1066481]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1066481]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-03-29 05:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found