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

Replies are listed 'Best First'.
Re^3: How do I remove newline character from a number got from unix command
by Tux (Canon) 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!
Re^3: How do I remove newline character from a number got from unix command
by hdb (Monsignor) on Sep 04, 2013 at 12:30 UTC