On Thu, 6 Jan 2005, Tim Wolak wrote:

> I am in need of a quick way to get the current date in the YYYYMMDD 
> format.  This is something I would like to understand better on how to 
> get the date with perl.  Any suggestions would be most welcome.


You need to read up on localtime.

-----------------------------------------------
#!/usr/bin/perl -w

use strict;

my ($sec,$min,$hour,$mday,$mon,$year) = (localtime)[0,1,2,3,4,5];
$year=$year+1900;
$mon=$mon+1;

printf("%02d%02d%02d", $year,$mon,$mday);
-----------------------------------------------


Owen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to