Can I answer saying:
Um Mitternacht gehe ich ins Bett.
OR
Ich gehe um Mitternacht ins Bett
Which one is more idiomatic (more correct)
I know that time have to precede ins Bett
Ich gehe um Mitternacht ins Bett
is correct.
The answer
Um Mitternacht gehe ich ins Bett.
is also correct, but it has a little harsh touch.
As an example: If you sit in a bar and somebody mention, that there is a midnight soup and everybody can get it, then you could react with a Um Mitternacht gehe ich ins Bett. With this reaction you show your incomprehension about doing anything else then sleeping at this time.
An Aber um Mitternacht gehe ich ins Bett is a neutral information (Like "Sorry for this, I can't take part, that's my timeto go to sleep").
But as always, it really depends on the situation. With a grin on your lips it can also be an ironic remark.
Word order in German is essentially free if the verb is in second position of main clauses. We have three moveable fragments thus six possibilities:
Ich gehe um Mitternacht ins Bett. (1)
Ich gehe ins Bett um Mitternacht. (4)
Um Mitternacht gehe ich ins Bett. (2)
Um Mitternacht gehe ins Bett ich. (8)
Ins Bett gehe ich um Mitternacht. (2)
Ins Bett gehe um Mitternacht ich. (9)
They differ only in the amount of tension included. The larger the number in brackets the higher I perceived the tension and thus the more unusual the sentence seems. More tension is often associated with emphasis: The third sentence emphasises midnight while the fifth emphasises going to bed.
Putting the subject last, especially if it is ich, is possible but highly unusual if you’re not Yoda thus the high tensions of four and six. The second sentence emphasises the going to bed bit more than the midnight bit but not strongly.
Both are correct, but in this context the second is a little more correct, because the first answer is related to the fact and the second to the time. You can use both, but because he asks for the hour, the second answer is more correct.
But in coll. use you can just tell the time, i.e. "Um Mitternacht".