Calculating the difference between two dates
Sorry guys,
Its late, and my brain isnt working. Im trying to calculate the difference between two dates. Doing this by taking Todays date is subtracting it from the Target date. Im getting todays date with date +%s to get time since the epoch, but how do i convert the other time to it? (there are a few examples, one of which is time since the last boot) Using the command who -b how do i convert into UNIX time? (Or is there a better way of doing it?) Cheers |
In 'man date' :
Quote:
date -d "$(who -b|tr -s " "|cut -d " " -f 4-)" +%s The 'tr' command eliminates the multiple spaces at the start of the output string, and the 'cut' command extracts only the date and time. $(...) gives the output of the command inside it. |
All times are GMT -5. The time now is 09:48 PM. |