TimeRemaining
TimeRemaining[] gives the number of seconds remaining until the earliest enclosing TimeConstrained will request the current computation to stop.
Examples
TimeConstrained[While[True, If[TimeRemaining[] < 0.5, Break[]]]; "done", 2]TimeConstrained[TimeRemaining[], 5]Please visit the official Wolfram Language Reference for more details.