LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-24-2004, 01:54 PM   #1
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Rep: Reputation: 51
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

Last edited by cccc; 02-24-2004 at 01:55 PM.
 
Old 02-25-2004, 05:10 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
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;
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM
date/time in c++ 1337 Twinkie Programming 3 01-01-2005 12:23 AM
Display the date and time from another time zone lothario Linux - Software 4 07-31-2004 03:27 PM
Date and Time mairul Debian 7 12-25-2003 12:26 PM
Date and time. vexer Slackware 2 08-13-2003 10:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration