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.


I believe this is the command you need:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.