Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date conversion problem...

Status
Not open for further replies.

suhaimi

Technical User
Aug 3, 2001
71
US
Hi all,
Is there a unix function to change a particular date string to a different date format?????
eq: 25/11/2001 convert to 25-Nov-01
31-Aug-2001 convert to 20010831
I know there is a long way to do it: use case/switch to convert. eg case $1
"Jan") val=1;;
"Feb") val=2;;
:
:
Is there any simple method to do the conversion?????

Thanks,
Suhaimi
 
To get the the date in the the format 13-Nov-01, you can use date +%d-%h-%y

Look at man strftime for a full list of options for formatting the current date.

Now, if you want to format a different date other than the current date (i.e. not using the date command) ... that's not so easy. Nigh on impossible in fact :)

Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top