code: def timedelta2millisecond(td):
      
      milliseconds = td.days * 24 * 60 * 60 * 1000
      milliseconds += td.seconds * 1000
      milliseconds += td.microseconds / 1000
      return milliseconds
docs: Get milliseconds from a timedelta.