I want to print the time on the serial monitor at the start and end of a signal (Help)

+1. My guess, since I have to guess, is that X is an integer and somewhere you increment it to change the flow of the code.

Entire sketch pls OR a complete small sketch, setup() through loop(), compiles &c., that we can run for ourselves, that shows your attempt to get the behaviour you seek.

a7