Support the ongoing development of Laravel.io →
Eloquent Views
Last updated 2 years ago.
0

isYesterday is a method on the instance, you need to change your if block to be

@if($post->created_at->isYesterday())
Last updated 2 years ago.
0

Great, many thanks. It works. How to Output if a method on the instance?

Example. How to Output the "SATURDAY?

Like this?

{{ $post->created_at->isWeekday(dayOfWeek) }}
   /**
    * Determines if the instance is a weekday
    *
    * @return boolean
    */
   public function isWeekday()
   {
      return ($this->dayOfWeek != self::SUNDAY && $this->dayOfWeek != self::SATURDAY);
   }

   /**
    * Determines if the instance is a weekend day
    *
    * @return boolean
    */
   public function isWeekend()
   {
      return !$this->isWeekDay();
   }
Last updated 2 years ago.
0

You can check all the available methods here:

https://github.com/briannesbitt/Carbon

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

HenLab henlab Joined 8 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.