Skip to main content
added 77 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k

With shell builtins:

  • zsh (4.1.1 (2003) and above) :

     $ zmodload zsh/datetime $ TZ=UTC0 strftime %c 1282368345 Sat 21 Aug 2010 05:25:45 UTC 
  • ksh93 (ksh93i (2000) and above):

     $ TZ=UTC0 printf '%(%c)T\n' '#1282368345' Sat Aug 21 05:25:45 2010 
  • bash (4.2 (2010) and above):

     $ TZ=UTC0 printf '%(%c)T\n' 1282368345 Sat 21 Aug 2010 05:25:45 UTC 

In all those, replace %c with the strftime() format you want.

With shell builtins:

  • zsh:

     $ zmodload zsh/datetime $ TZ=UTC0 strftime %c 1282368345 Sat 21 Aug 2010 05:25:45 UTC 
  • ksh93:

     $ TZ=UTC0 printf '%(%c)T\n' '#1282368345' Sat Aug 21 05:25:45 2010 
  • bash:

     $ TZ=UTC0 printf '%(%c)T\n' 1282368345 Sat 21 Aug 2010 05:25:45 UTC 

In all those, replace %c with the strftime() format you want.

With shell builtins:

  • zsh (4.1.1 (2003) and above) :

     $ zmodload zsh/datetime $ TZ=UTC0 strftime %c 1282368345 Sat 21 Aug 2010 05:25:45 UTC 
  • ksh93 (ksh93i (2000) and above):

     $ TZ=UTC0 printf '%(%c)T\n' '#1282368345' Sat Aug 21 05:25:45 2010 
  • bash (4.2 (2010) and above):

     $ TZ=UTC0 printf '%(%c)T\n' 1282368345 Sat 21 Aug 2010 05:25:45 UTC 

In all those, replace %c with the strftime() format you want.

Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k

With shell builtins:

  • zsh:

     $ zmodload zsh/datetime $ TZ=UTC0 strftime %c 1282368345 Sat 21 Aug 2010 05:25:45 UTC 
  • ksh93:

     $ TZ=UTC0 printf '%(%c)T\n' '#1282368345' Sat Aug 21 05:25:45 2010 
  • bash:

     $ TZ=UTC0 printf '%(%c)T\n' 1282368345 Sat 21 Aug 2010 05:25:45 UTC 

In all those, replace %c with the strftime() format you want.