|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Another date conversion question
I'm new to the world of UNIX and scripting so please bear with me. Is there a built in function or a method to convert
07312006 to 31-Jul-06 I'm having a tough time trying to find a convert function for converting the numeric month to an abbr. month . Is there a way to do this without using a case statement? Thanks for you time! |
|
#2
|
|||
|
|||
|
Using only shell:
Code:
#!/bin/ksh
num_to_month()
{
set -A mnames Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
typeset -i index="$1"
index=index-1
if [[ $index -lt 12 ]] ; then
echo ${mnames[index]}
else
echo "Invalid month number"
fi
}
num_to_month 01
num_to_month 02
num_to_month 03
num_to_month 04
num_to_month 05
num_to_month 06
num_to_month 07
num_to_month 08
num_to_month 09
num_to_month 10
num_to_month 11
num_to_month 12
num_to_month 13
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Another date conversion question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|