Delay controlled relay sketch issues

Thank you all for your attention and comments.
I apologise for the wrong way i posted my code....

The case study to deal with is:
At start, output (pin 12) is low.
while input (pin 2) is high, pin 12 is high too.
when input goes low, a count down of 30 mins begins and output remains high until this period expires. then it goes low......
If input goes high again within these 30 mins, I need output to stay high as long as input is high and the count down to reset and start counting from the beginning when input goes low again etc etc........

Please advise the simplest you can, as this is my first step in programming......