|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
use POSIX qw(strftime);
my $adate = strftime("%y%m%d", localtime(time)); $adate = conc($adate, "_143635323.xml") print $adate #20060320_143635323.xml |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Displaying Date/Time Formats |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|