Hi,
the users input of my app is "HH:MM:SS" like 01:34:10. However, I would like to convert it to seconds before saving it into my database. I can't successfully do it at the beforeCreate model. I have to do it at the controller, which isn't good.
This isn't working:
public function beforeCreate() {
// Convert date to german date
$date = new DateTime($this->date);
$this->date = $date->format('Y-m-d');
// Convert HH:MM:SS to seconds
$duration = $this->duration;
$this->duration = strtotime("1970-01-01 $duration UTC");
}
Converting the date to german date is working but not second conversion. What I am doing wrong?