LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to get a new subdirectory with date and time ? (https://www.linuxquestions.org/questions/programming-9/how-to-get-a-new-subdirectory-with-date-and-time-150026/)

cccc 02-24-2004 01:54 PM

how to get a new subdirectory with date and time ?
 
hi

I have in a perl script following lines to create a subdirectory with date

my @dt = localtime;
my $subfolder_name = ((1900 + $dt[5]) * 100 + 1 + $dt[4]) * 100 + $dt[3];
mkdir "/tmp/$subfolder_name" or die "$subfolder_name: $!";

and subdirectory will be created like 20040220

but howto change it to get the date and time like 200402200800 ?

regards
cccc

jim mcnamara 02-25-2004 05:10 PM

try something like:
Code:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $subfolder_name = ((1900 + $dt[5]) * 100 + 1 + $dt[4]) * 100 + $dt[3] + $hour + $min;



All times are GMT -5. The time now is 02:01 PM.