Only show content before or after a given date/time

Submitted by mattstauffer - 6 years ago

Use Carbon lt() and gt() in the view to only show certain content if it's before or after a current date/time.

@if (Carbon\Carbon::now()->lt(Carbon\Carbon::create(2018, 5, 25, 4, 0, 0, 'America/New_York')))
    Show thing here that will only display until May 25, 2018 at 4am New York time
@endif

@if (Carbon\Carbon::now()->gt(Carbon\Carbon::create(2018, 5, 25, 8, 0, 0, 'America/New_York')))
    Show thing here that will only display *after* May 25, 2018 at 8am New York Time
@endif