Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

102
Visualizações
Adding day/incrementing with a carbon formatted date

I'm using carbon to get today's date and format it in a laravel blade template, which is not a problem at all, but when it comes to incrementing I'm having an issue

I'm currently testing with just adding a single day, but I want to actually create table headers for today and the next 7 days.

In my blade I have:

<?php 
use Carbon\Carbon;
$date = Carbon::now()->format('m/d/Y');
?>

<thead>
  <tr>
    <th>{{$date}}</th>
    <th>{{$date->addDay()}}</th>
  </tr>
</thead>

But it's saying that I'm calling addDay on a string, which makes sense because I'm formatting the date that way.

Is there a way I can keep this date format of mm/dd/yyyy but also create a loop using something like addDay on that format? I just want to increment for the next 7 days and use those dates as table headers

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

could you try this

<?php 
use Carbon\Carbon;
$format = 'm/d/Y';
$date = Carbon::now();
?>

<thead>
  <tr>
    <th>{{$date->format($format)}}</th>
    <th>{{$date->addDay()->format($format)}}</th>
  </tr>
</thead>

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda