Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: How do I remove newline character from a number got from unix command

by tousifp (Novice)
on Sep 04, 2013 at 12:22 UTC ( #1052318=note: print w/ replies, xml ) Need Help??


in reply to Re: How do I remove newline character from a number got from unix command
in thread How do I remove newline character from a number got from unix command

How can I have date and month in a similar fashion? I need like this : 2013-09-04 and "Sep 04"


Comment on Re^2: How do I remove newline character from a number got from unix command
Re^3: How do I remove newline character from a number got from unix command
by hdb (Prior) on Sep 04, 2013 at 12:30 UTC
Re^3: How do I remove newline character from a number got from unix command
by Tux (Monsignor) on Sep 04, 2013 at 12:37 UTC
    my $date_as_YYYY_MM_DD = do { my @d = localtime; sprintf "%04d-%02d-%02d", $d[5] + 1900, ++$d[4], $d[3]; };

    but that is most likely better done with POSIX' strftime:

    use POSIX qw( strftime ); my $d_YMD = POSIX::strftime ("%Y-%m-%d", localtime); my $d_Md = POSIX::strftime ("%d %b", localtime); # I prefer 04 Sep ov +er Sep 04

    Enjoy, Have FUN! H.Merijn
      t a n k s!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2014-09-20 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls