Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I wrote a code which convert epoch time to readable time

sd=`date -d '1970-01-01 UTC '$SDATE' seconds' +"%d-%m-%Y"`

the output is : 27-12-2002 but I want the output to be : 27/Nov/2002

how should i change my code?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

sd=`date -d '1970-01-01 UTC '$SDATE' seconds' +"%d/%b/%Y"

I believe

share|improve this answer
add comment

There's a shortcut for "time from unix stamp": date -d @$STAMP. For the output, read man date

share|improve this answer
add comment

Use %b instead:

sd=`date -d '1970-01-01 UTC '$SDATE' seconds' +"%d/%b/%Y"`

Read man date for more details:

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.