Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
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 having a coffee break in the Monastery: (4)
As of 2024-06-20 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.