In the given problem, A has committed an offence punishable with imprisonment up to 3 years. Hence, cognizance can be taken before expiry of a period of 3 years. But in computing the period of limitation the time during which the offender has been out of India or from any territory outside India shall be excluded.
Hence, the Magistrate can taken cognizance because, the span of time from 2012 to 2018 will not be included in computation to period of limitation, as during this period A was absent from India.