How to display Unix time in the timestamp format?

29

6

I'm looking for a way to display my time in Debian Linux as a timestamp, e.g.

1279628325

I can't find any options to do that with the date command. Any ideas?

user32433

Posted 2010-07-20T12:20:33.173

Reputation: 347

Answers

58

You can do this with

date +%s

For more possibilities, see

man date

Tamara Wijsman

Posted 2010-07-20T12:20:33.173

Reputation: 54 163

1

note this is not POSIX http://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html

– Steven Penny – 2018-05-27T02:05:58.253

2

My favorite way:

perl -e 'print time'

Andrew Palmer

Posted 2010-07-20T12:20:33.173

Reputation: 129

1

srand without a value uses the current timestamp with these Awk implementations:

  • gawk
  • gawk --posix
  • mawk 1.3.3
  • nawk

so you can use Awk:

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

Or the awk Velour library:

velour -n 'print t_now()'

Steven Penny

Posted 2010-07-20T12:20:33.173

Reputation: 7 294