Insert file date created into a variable

C

Chris Petersen

Is there a better/simpler way than this?

use POSIX ('strftime');
my $dateCreated = strftime "%b %d, %Y %H:%M", localtime
((stat("c:\\test.txt"))[10]);

How would I go about displaying the output in this format: 20031105
14:00? Any advice of links would be appreciated. Thanks in advance
-Chris
 
E

Eric J. Roode

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

(e-mail address removed) (Chris Petersen) wrote in
Is there a better/simpler way than this?

use POSIX ('strftime');
my $dateCreated = strftime "%b %d, %Y %H:%M", localtime
((stat("c:\\test.txt"))[10]);

How would I go about displaying the output in this format: 20031105
14:00? Any advice of links would be appreciated. Thanks in advance
-Chris

This is why I wrote Time::Format. I got sick of looking up the awkward
strftime %-codes, and was tired of having to make do when they weren't
flexible enough.

use Time::Format;
my $dateCreated = time_format('yyyymmdd hh:mm',(stat $file)[10]);

http://search.cpan.org/~roode/Time-Format-0.13/Format.pm

Hope it helps.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

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

iQA/AwUBP6mISWPeouIeTNHoEQLZQwCgnh5zmXI0rLBQYUzcMWpEU/T4dO0An28m
Qv8YB1yVKzx0ofBrlLrcFPfw
=0SEz
-----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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top