0

I would like to make a script that checks the date.

If the given date is today: return true else .... return false.

I have something like that.

    $end = Carbon::createFromFormat('Y-m-d H:i:s', $this->end_time);
    $date = Carbon::createFromDate($end->year, $end->month, $end->day, 'Europe/Warsaw');

    if($date->diffInDays() == 0){
        // It's today.
        return true;
    }

(I need to have this time conversion because I'm from Poland and I have other time)

However, I do not know why this does not work.

if($date->diffInDays() == 0){
    // It's today.
    return true;
}
chmod
  • 33
  • 6
  • Why dont you log some values and see? like the value of $date->diffInDays() – Eenvincible Apr 21 '17 at 21:06
  • Possible duplicate of [Calculate difference between two dates using Carbon and Blade](http://stackoverflow.com/questions/39508963/calculate-difference-between-two-dates-using-carbon-and-blade) – Gntem Apr 21 '17 at 21:30

1 Answers1

0

Have a look at DateTime::diff There you can find all informations needed to solve your pproblems

jiGL
  • 175
  • 8