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

Re: Epoch to specific output

by Utilitarian (Vicar)
on Jan 02, 2014 at 16:45 UTC ( #1068983=note: print w/ replies, xml ) Need Help??


in reply to Epoch to specific output

Something like the following (substituting your epoch value for time() )

$ perl -MPosix -E 'say POSIX::strftime("%m%d%H%M",localtime(time()))' 01021644
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."


Comment on Re: Epoch to specific output
Select or Download Code
Re^2: Epoch to specific output
by Anonymous Monk on Jan 02, 2014 at 16:58 UTC

    Thank you for the swift reply.

    The system that I am using does not have the Posix module installed. Is there a way to do this without that option?

      Use upper case: POSIX is a Core module installed with Perl.
      perl -MPOSIX -E 'say POSIX::strftime("%m%d%H%M",localtime(time()))'

        I am using Perl v5.8.4 on an Intel based machine with Solaris 10 64bit operating system.

        The capitalized POSIX was accepted but I am receiving other errors now.

        Input:
        perl -MPOSIX -E 'say POSIX::strftime("%m%d%H%M", localtime(1388679108))'

        Output:
        Unrecognized switch: -E (-h will show valid options).

        Input:
        perl -MPOSIX -e 'say POSIX::strftime("%m%d%H%M", localtime(1388679108))'

        Output:
        Bareword found where operator expected at -e line 1, near "say POSIX::strftime"
        (Do you need to prodeclare say?)
        Execution of -e aborted due to compilation errors.

      the POSIX module has been core since God was a boy, what version/environment are you on?

      print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1068983]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-12-28 04:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls