An image forming apparatus that operates in a normal mode in a first electric power state and a power saving mode in a second electric power state, more electric power being saved in the second electric power state than in the first electric power state, the image forming apparatus comprising: a sensor configured to detect a detection target to generate a detection signal indicating detection of the detection target; an operation section configured to receive an operation from the detection target to generate an operation signal indicating content of the operation from the detection target; and a controller configured to execute a first timer process in response to receipt of the detection signal from the sensor and execute a second timer process in response to receipt of the operation signal from the operation section, wherein the first timer process is a process of measuring an elapsed period from receipt of the detection signal from the sensor by the controller, the second timer process is a process of measuring an elapsed period from stoppage of receipt of the operation signal from the operation section by the controller, at a time when a first period elapses indicating that the first timer process times out, the controller transitions from the normal mode to the power saving mode, at a time when a second period elapses indicating that the second timer process times out, the controller transitions from the normal mode to the power saving mode, the first period is shorter than the second period, the image forming apparatus characterized in that: in a state in which the controller is in the normal mode, the controller does not reset the elapsed period measured in the first timer process even upon receiving the detection signal; in a state in which the controller is in the normal mode, the controller stops executing the first timer process upon receiving the operation signal from the operation section; and when the controller stops receiving the operation signal from the operation section, the controller starts executing the second timer process. a sensor configured to detect a detection target to generate a detection signal indicating detection of the detection target; an operation section configured to receive an operation from the detection target to generate an operation signal indicating content of the operation from the detection target; and a controller configured to execute a first timer process in response to receipt of the detection signal from the sensor and execute a second timer process in response to receipt of the operation signal from the operation section, wherein the first timer process is a process of measuring an elapsed period from receipt of the detection signal from the sensor by the controller, the second timer process is a process of measuring an elapsed period from stoppage of receipt of the operation signal from the operation section by the controller, at a time when a first period elapses indicating that the first timer process times out, the controller transitions from the normal mode to the power saving mode, at a time when a second period elapses indicating that the second timer process times out, the controller transitions from the normal mode to the power saving mode, the first period is shorter than the second period, the image forming apparatus characterized in that: in a state in which the controller is in the normal mode, the controller does not reset the elapsed period measured in the first timer process even upon receiving the detection signal; in a state in which the controller is in the normal mode, the controller stops executing the first timer process upon receiving the operation signal from the operation section; and when the controller stops receiving the operation signal from the operation section, the controller starts executing the second timer process. in a state in which the controller is in the normal mode, the controller does not reset the elapsed period measured in the first timer process even upon receiving the detection signal; in a state in which the controller is in the normal mode, the controller stops executing the first timer process upon receiving the operation signal from the operation section; and when the controller stops receiving the operation signal from the operation section, the controller starts executing the second timer process.