Bash: How do I get current Unix time in milliseconds?

How do I get the current unix time in milliseconds (i.e number of milliseconds since Unix epoch Jan 1 1970) ?

 

This:

date +%s  

will return the number of seconds since the epoch.

This:

date +%s%

returns the seconds and current nanoseconds.

So:

date +%s%N | cut -b1-13 

will give you the number of milliseconds since the epoch - current seconds plus the left three of the nanoseconds.

 

 

 

posted @ 2012-03-06 17:53  alxe_yu  阅读(377)  评论(0编辑  收藏  举报