Bash Timestamp - Get Unix timestamp in bash

Apr 4 2011

The current Unix timestamp is a numeric representation of the current date and time. The current timestamp may come in handy when checking when files were last modified or when an event occurred or something of the sort. To get the current Unix timestamp from a bash terminal we may use the following code:

date +%s

If we execute that command in a terminal, we get a really big number which represents the current date and time. We may see output like:

1302902881

For an explanation of how exactly this timestamp is calculated, please refer to our Date formatting tutorial. That link gives a brief introduction to Unix-like timestamps and will be useful in getting you up to speed with the concept of a timestamp.

We hope this brief tutorial on the bash timestamp has been helpful.

No votes yet

Post new comment

The content of this field is kept private and will not be shown publicly.
Image CAPTCHA
Enter the characters shown in the image.
Link to this Page