0

in our application, we want to show offers like valid for 5 hours, valid for 4 hours and so on till the offer expires, now problem is, even when the offer period expired, it shows valid for 1 hour and so on, this is how we are implementing carbon's diffForHumans()

function time_diff($type = null, $time = null)
{
   if(is_null($type) || is_null($time))
   {
      return 'moments ago';
   }
   else
   {
      $ist_time = Carbon::createFromFormat('Y-m-d H:i:s', $time);
      $ist_now = Carbon::now('Asia/Kolkata');
      return $ist_time->diffForHumans($ist_now, true);
   }
 }

what we expect

as soon as the offered is expired, we can show expired or we can hide it from the main page

what we want to know

how to know if time difference is > 0

runningmark
  • 738
  • 4
  • 13
  • 32

0 Answers0