Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!