Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How do I drop leading zeros from a date like 07/04/2001 to read 7/4/2001??

by c (Hermit)
on Nov 27, 2001 at 03:38 UTC ( [id://127659]=note: print w/replies, xml ) Need Help??


in reply to How do I drop leading zeros from a date like 07/04/2001 to read 7/4/2001??

Update:okay, i think that you can use the following code to get the desired results:

#!/usr/bin/perl -w use strict; use POSIX qw(strftime); my $date = strftime("%-m/%e/%Y", localtime);

the hyphen should flag that you do not want padding for the result of the month value of %m which by default will be padding in month represented by a single digit 1-9.

Update:It looks as though %m still pads the month with a zero. I'll start reading through POSIX::Strftime and see what I can find...

If you're using strftime, try using:

my $date = strftime("%m/%e/%Y",localtime);

humbly -c

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 00:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found