How Many Seconds Are There From This Time To This Time

I am trying to find the seconds difference from getTime to timestr but I don’t seem to understand where I am going wrong. I think it is because I am adding one to the min and hour regardless of where it has been 60 (time units) or not.

set timestr to "11:46:23 AM"
set text item delimiters to " "
set FutureEnding to text item 2 of timestr
set text item delimiters to ":"
set FutureHour to text item 1 of timestr
set FutureMin to text item 2 of timestr
set FutureSec2 to text item 3 of timestr
set text item delimiters to " "
set FutureSec to text item 1 of FutureSec2


set getTime to "7:37:12 PM"
set text item delimiters to " "
set theEnding to text item 2 of getTime
set text item delimiters to ":"
set theHour to text item 1 of getTime
set theMin to text item 2 of getTime
set theSec1 to text item 3 of getTime
set text item delimiters to " "
set theSec to text item 1 of theSec1

if theEnding = "PM" then
	set theHour to theHour + 12
end if

if FutureSec = "00" then
	set FutureSec to 60
end if
set SecondsLeft to FutureSec - theSec
set theMin to theMin + 1
if FutureMin = "00" then
	set FutureMin to 60
end if
set MinLeft to FutureMin - theMin
set theHour to theHour + 1


set HoursLeft to theHour - FutureHour
display dialog theHour
display dialog FutureHour
set HIHI to (24 - theHour) + FutureHour
display dialog HIHI
if HoursLeft < 0 then set HoursLeft to -HoursLeft

set SecondsToDelay to (HoursLeft * 60 * 60) + (MinLeft * 60) + (SecondsLeft)
display dialog SecondsLeft
display dialog MinLeft
display dialog HoursLeft
display dialog SecondsToDelay

Try this:

set timestr to date "Wednesday, May 11, 2011 11:46:23 AM"
set getTime to date "Wednesday, May 11, 2011 7:37:12 PM"

set timedif to getTime - timestr

result → 28249

If you don’t want to rely on the user’s time format preference matching the format of date string:

on timestringToSec(timestr)
	set {h, m, s} to words 1 thru 3 of timestr
	if (timestr ends with "AM") then
		set h to h mod 12
	else if (timestr ends with "PM") then
		set h to h mod 12 + 12
	end if
	
	return h * hours + m * minutes + s
end timestringToSec

on secToHHMMSS(sec) -- Assumes input < 100 hours.
	tell (1000000 + sec div hours * 10000 + sec mod hours div minutes * 100 + sec mod minutes) as text
		return text 2 thru 3 & ":" & text 4 thru 5 & ":" & text 6 thru 7
	end tell
end secToHHMMSS

set timestr to "11:46:23 AM"
set getTime to "7:37:12 PM"

set futureSec to timestringToSec(timestr)
set currentSec to timestringToSec(getTime)

set SecondsToDelay to (futureSec - currentSec + days) mod days --> 58151
display dialog secToHHMMSS(SecondsToDelay) --> "16:09:11"