Returning linux timestamp


To return linux timestamp use the following:

Date and time now in timestamp format:
date "+%s"

A specific date and time in timestamp format:

date -d "<time>" "+%s"
e.g. date <del>d "2014</del>01-30 15:00:00" "+%s"
</time>

Date and time now in timestamp format and nano seconds:

date "+%s%N"

Date and time now in timestamp format and milli seconds:

date “+%s%N” | cut -b1-13
or
echo $(($(date “+%s%N”)/1000000))

To return a specific date and time in timestamp with nano or milli seconds then simply add -d parameter similar to the previous example.

  1. No comments yet.
(will not be published)
*