Would it be more efficient to store only the start date and duration, calculating the end value when needed?

Storing only the start date and duration can be more efficient as it reduces the amount of data that needs to be stored. The end value can be easily calculated by adding the duration to the start date whenever it is needed, saving storage space and simplifying data management.

class Event {
    private $startDate;
    private $duration;

    public function __construct($startDate, $duration) {
        $this->startDate = $startDate;
        $this->duration = $duration;
    }

    public function getEndDate() {
        return date('Y-m-d H:i:s', strtotime($this->startDate) + $this->duration);
    }
}

// Usage
$event = new Event('2022-01-01 00:00:00', 3600); // Start date and duration in seconds
echo $event->getEndDate(); // Outputs the calculated end date