My requirement is to get difference of 2 timestamps in hours.

As the date diff option is taking long for me to figure out I am trying to convert both dates in to YYYYMMDDHHMMSS format and find the number difference. So I need to get the current date and time in the same format.

1 Answer 1


I believe this is the command you need:

date '+%Y%m%d%H%M%S'
  • 1
    oh thanks !! i did try this but had made a typo err. thank you
    – xGen
    Sep 25, 2015 at 6:00
  • 2
    For ISO 8601 date format use: date '+%Y-%m-%d'
    – Emil
    Nov 15, 2018 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .