Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Want to format date and time

by 2teez (Priest)
on Nov 17, 2012 at 18:49 UTC ( #1004338=note: print w/ replies, xml ) Need Help??


in reply to Want to format date and time

Hi Joyeux,
If I get you right, you probabily want to display your current date, in some format. If so, you can do like so:

use warnings; use strict; my ( $day, $month, $year ) = (localtime)[ 3 .. 5 ]; print sprintf "%s : %s : %s\n", $day, $month + 1, $year + 1900, $/; #OR use POSIX qw(strftime); print strftime "%d - %m - %Y\n", localtime; #OR use Time::localtime; my $tm = localtime; my $day = $tm->mday(); my $month = $tm->mon() + 1; my $year = $tm->year() + 1900; print sprintf "%s \\ %s \\ %s", $day, $month, $year;
You might also like to check this module on CPAN Date::Calc, Date::Manip

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re: Want to format date and time
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-09-18 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (115 votes), past polls