Running out of Time in War while Attacking
Solution 1:
You will have the full 3 minutes to perform your attack if you start your attack with at least 1 second left on the war clock. It will not stop your attack and force a surrender as long as you do so.
However, once the war clock reaches 0, no new attacks can take place and the war will end once the final attacks are completed.
Source: I have done this before a few times, lost to this a few times, forums, and here is a youtube clip of this.
(screenshot is from the youtube clip linked above)