3

What command can I use in linux to display the time in unix format i.e. no of seconds since epoch (01/01/1970)?

Bourne
  • 1,815
  • 12
  • 33
  • 52
  • possible duplicate of [get current time in seconds since the Epoch on Linux, Bash](http://stackoverflow.com/questions/1092631/get-current-time-in-seconds-since-the-epoch-on-linux-bash) – Alex K. Jun 10 '13 at 14:21
  • 1
    Check the man pages for stuff like this, it'll save you time - looking at `man date` will show you this note: `%s seconds since 1970-01-01 00:00:00 UTC` – Mike Jun 10 '13 at 14:21

3 Answers3

7

You should use date command with format: date +%s

Ye Liu
  • 8,906
  • 1
  • 37
  • 33
4

Just use this command:

date +%s
Igor Chubin
  • 57,130
  • 8
  • 114
  • 135
4

GNU and BSDs:

date +%s

With most Awk implementations:

awk 'BEGIN{srand(); print srand()}'

Probably the most portable out of Linux:

perl -le 'print time'

With shell builtin, ksh93 or Bash 4.1 or above:

printf '%(%s)T'

With shell builtin, zsh:

zmodload zsh/datetime
echo "$EPOCHSECONDS"
Zombo
  • 1
  • 55
  • 342
  • 375
Stephane Chazelas
  • 5,511
  • 2
  • 29
  • 29