UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 24th, 2006, 04:31 PM
crode02 crode02 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 2 crode02 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 48 sec
Reputation Power: 0
Displaying Date/Time Formats

I am having trouble figuring out how the time in a date/time stamp can be created in this format: 20060320_143635323.xml

How can I generate the time in this format ( other than, H%M%S%...) ?

Thanks in advance.

crode02

Reply With Quote
  #2  
Old March 26th, 2006, 09:19 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,357 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 7 h 10 m 45 sec
Reputation Power: 787
Welcome to Dev Shed. Please visit the Rules/Guidelines forum and find and read a thread entitled, "How to post a question." There's not enough information for us (me anyway) to help you.
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Last edited by jharnois : March 26th, 2006 at 09:22 AM. Reason: Added Dev Shed greeting.

Reply With Quote
  #3  
Old March 27th, 2006, 04:29 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 727 SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 3 h 40 m 36 sec
Reputation Power: 315
I would sggest a peek at the man pages for the date command - you would be looking at something like `date +%Y%m%d_%H%M%S` - not sure off the top of my head about time less than seconds - but they may be available. The backticks (The ``) charaters mean, in efefct, execute in place and substitute with the output of the command, thus if you were to to something like:

my_command > `date +%Y%m%d_%H%M%S`.xml

Any output (from stdout) would be sent to a file named with the date/time of when the command was issued, with .xml added on to the end.

If you will need to refer to this file later - you MAY have issues - like, just what was the date/time when that command ran ...? In cases like that chuck the date into a variable and use that instead ...

File_date=`date +%Y%m%d_%H%M%S`

my_command > ${File_date}.xml

.
.
.
.
Then, much later, you can refer to the file again with ease, as the date/time is stored in the variable, maybe to check if a particular entry was made (this is just an example!):

grep "entry=$SEARCH" ${File_dat}.xml

Reply With Quote
  #4  
Old April 3rd, 2006, 01:37 PM
hamboy hamboy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 88 hamboy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 29 m 18 sec
Reputation Power: 0
use POSIX qw(strftime);
my $adate = strftime("%y%m%d", localtime(time));
$adate = conc($adate, "_143635323.xml")

print $adate

#20060320_143635323.xml

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Displaying Date/Time Formats


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway