mercredi 31 juillet 2019

Display total days between two dates if status is completed

I am trying to count the number of days between two dates the carbon::now and $start_date and when the status == complete the counting of days stops then get the total number of days.

if ($this->status === 'COMPLETED') {
    $now = Carbon::now();
    $start_date = Carbon::createFromFormat('Y-m-d', $this->start_date);
    $this->start_date_to_current_date = $start_date->diffInDays($now, true);
}

But the problem is, the days still continues to count even the status is completed like for example the total days is 3 then in the next day it becomes 4. Why is that ? :/



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire