Shelf life is determined through stability testing, which involves subjecting a product to various environmental conditions such as temperature, humidity, and light. These tests help identify any changes in the chemical composition over time. The results are used to establish expiration dates, ensuring that products are used within a timeframe that guarantees their safety and effectiveness.