Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Answer: How can I format the output of localtime?

by cLive ;-) (Prior)
on Feb 09, 2004 at 16:58 UTC ( [id://327666]=note: print w/replies, xml ) Need Help??


in reply to Re: How can I format the output of localtime?
in thread How can I format the output of localtime?

Dude, I really think you need to read up on sprintf!
sub TimeStamp { my($format) = $_[0]; my ($sec,$min,$hour,$mday,$mon,$year) = localtime(); $year+=1900; $mon++; if ($format == 1) { return sprintf("%4d-%02d-%02d %02d:%02d:%02d",$year,$mon,$mday +,$hour,$min,$sec); } elsif ($format == 2) { return sprintf("%02d%02d%4d",$mon,$mday,$year); } elsif ($format == 3) { return sprintf("%02d%02d%02d",$year%100,$mon,$mday); } elsif ($format == 4) { return sprintf("%02d%02d%02d",$mon,$mday,$year%100); } elsif ($format == 5) { return sprintf("%4d%02d%02d%02d%02d%02d",$year,$mon,$mday,$hou +r,$min,$sec); } elsif ($format == 6) { return sprintf("%4d%02d%02d",$year,$mon,$mday); } elsif ($format == 7) { return sprintf("%02d/%02d/%4d %02d:%02d:%02d",$mday,$mon,$year +,$hour,$min,$sec); } elsif ($format == 8) { return sprintf("%4d%02d%02d%02d%02d",$year,$mon,$mday,$hour,$m +in); } else { return sprintf("%02d/%02d/%4d",$mday,$mon,$year); } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-19 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found