elapsed time calculation from two date strings - shell script
Looking for help.
Have got two variables defined as below. Actually the values are date strings (yyyymmddHHMMSS year month day 24hour min second) x1="20120228204515" x2="20120228204936" Looking for some logic (that could be used in shell script) to find the difference of x2 and x1 in terms of seconds (or minutes). Thanks. |
Easiest way IMHO would be to not use time stamps but epoch instead as that's easier to work with. Note the 'date' command can convert human readable dates to epoch and back in about every format you can think of.
|
Thanks for your response. Actually in our case the timestamp values (x1 and x2) are already stored in flat files for thousands of records and I need to calculate the elapsed time for these records. We get this flat file from another interface system where we don't have much control. In my original post I gave a simplified requirement by defining two variables x1 and x2. Thanks.
|
This may explain on stdout what I mean:
Code:
x1="20120228204515" |
That's great. It resolved the issue. Thanks a lot.
|
Moderator response
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of ; http://www.linuxquestions.org/questi...trings-936808/
|
All times are GMT -5. The time now is 03:11 AM. |