need 2 digit dd/mm output

B

Bob

x-no-archive:yes

need to have host get date and use in outputfile name. mon and day has to
be two digits.
ex: spc20030702.kdg

ex:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday)=localtime(time);
print "spc$year$mon$mday.kdg\n";

results in: spc2003718.kdg and I need spc20030718.kdg
thanks
 
B

Bob

Vladimir P. said:
need to have host get date and use in outputfile name. mon and day has to
be two digits.
ex: spc20030702.kdg
Here is one way of doing it:

($yr,$mon,$day) = (localtime)[5,4,3];
$yr+=1900,$mon++;
printf "spc%4d%02d%02d.kdg",$yr,$mon,$day;

is there a way to get "spc%4d%02d%02d.kdg",$yr,$mon,$day; in a
variable...
like $filename = "spc%4d%02d%02d.kdg",$yr,$mon,$day;

so I can do
print $filename "something";
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

need to have host get date and use in outputfile name. mon and day
has to be two digits.
ex: spc20030702.kdg

ex:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday)=localtime(time);
print "spc$year$mon$mday.kdg\n";

results in: spc2003718.kdg and I need spc20030718.kdg
thanks

Use my new Time::Format module (available on CPAN, and from ActiveState's
repository).

use Time::Format;
$filename = "spc$time{yyyymmdd}.kdg";

- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPxk00WPeouIeTNHoEQL2GwCfXI0I2VDpqyw7scFEFAf8zPmo0qsAoJUv
FKAz2L3BTmABrBesMaAJ22/O
=gHa7
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

localtime(time()) 16
Need help with this script 4
Date Problem 6
time configuration for localtime 8
localtime and mktime 2
time format +1 hour 15
chenga script to show one houer more 7
TimeDate conversion to string. 8

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,301
Latest member
BuyPureganics

Latest Threads

Top