You could parse the string of date and time and conveniently fill the fields of a struct tm, then use mktime () to obtain calendar time and use difftime () to compute the difference. The result of this function is in seconds, so you may need to reformat it in case you want to show it in hh:mm:ss or other formats.