On Wed, 20 Sep 2006 [EMAIL PROTECTED] wrote:

> Hello
> 
> I am looking for some simple perl functions that will return the current date 
> and time in string format. The purpose is to create a file with part of the 
> name being the date and time.


I use something like this

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

my $file_base_name = "foo";
my $t              = time();

my $file_name = "$file_base_name$t";

print "$file_name\n";

# or if you requite somthing more readable

my @t = localtime();

my $file_name_identifier =
  sprintf( "%04d%02d%02d", $t[5] + 1900, $t[4] + 1, $t[3] );

$file_name = "$file_base_name$file_name_identifier\n";

print "$file_name\n";
--------------------------------------------------------------


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