Hello Lilly. How are you?
That and When can be used interchangeably in the first sentence.
In the second sentence That and When are also interchangeable.
I think you will begin to see the differences in usage, when you begin to see sentences where When is the first word of the sentence, and you see that the word That will not work as the first word of the sentence at all.
That, most often appears in the middle of a sentence, to refer back to a previous statement, such as: "It was at Six O'clock....etc.".
Consider this sentence:
When I was a child, I thought like a child, and acted like a child; but when I became a man, I put away the things of childhood.