DateTime in militaryformat

I am trying to get a time variable that always uses 4 digits to represent the time as per below. I have tried the following string slotStartTimeInMilitaryFormat = $”{timeSlotsStartTime.Hour}{…