You can usually tell when a jar has been opened. When you first open it or press down on the lid and release, it pops up. This behavior is a great mechanism for a one-way switch on a timer (day counter) that starts counting days once the seal has been broken and the lid flexes up. A two digit display starts at 0 and goes up to 99. After 99 days, I don’t know about you, my jar of salsa is getting dumped!
It would be too expensive now, but with continued advancements toward very cheap disposable circuit boards (pdf), this should be possible and maybe even cost effective in 10-15* years. I imagine in 20-25* years many shelf safe but perishable consumer products, intended to be refrigerated in the purchased container, will have some kind of electronic dating as part of the apparently never ending competition for consumer market-share.
Improvements on this could be tracking what the peak temperature the product reached after opening, how long has the product been at certain temperature levels, possibly even microbe sensors to check for botulism and other baddies. The possibilities are great!
*This is merely an educated guess based on the technology and consumer trends I’ve observed.