Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Dateless in Denver...

by Thelonius (Priest)
on Aug 11, 2006 at 16:35 UTC ( [id://566884]=note: print w/replies, xml ) Need Help??


in reply to Dateless in Denver...

my $mdyt = `date '+%m/%d/%Y %H:%M:%S'`;
It displays correctly because the date command is outputting it to stdout, not because of "print $mdyt".

You could also say (a bit more efficient)

use POSIX; my $mdyt = strftime('+%m/%d/%Y %H:%M:%S', localtime(time));

Replies are listed 'Best First'.
Re^2: Dateless in Denver...
by jwkrahn (Abbot) on Aug 11, 2006 at 22:42 UTC
    The '+' character is how the date command recognizes the format, POSIX::strftime will just return a literal '+' character so:
    use POSIX 'strftime'; my $mdyt = strftime '%m/%d/%Y %H:%M:%S', localtime;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-28 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found