Determining the lifetime of long-lived particles at the HL-LHC