1

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?

matarsak
  • 37
  • 5

3 Answers3

3

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

I believe

Dan
  • 15,430
  • 1
  • 36
  • 67
2

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

Creshal
  • 259
  • 1
  • 5
  • 16
1

Use %b instead:

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

Read man date for more details:

quanta
  • 51,413
  • 19
  • 159
  • 217