I'm trying to get a future date from today using PHP.
like date('dS M, Y (D)')
returns 21st Jan, 2021 (Thu) (Today)
How can we get a future date from today!
My Answer:
You can achieve this in Laravel using the Carbon library, which provides a fluent interface for working with dates and times in PHP. Here's how you can get a future date 10 days from today:
php
use Carbon\Carbon;
$futureDate = Carbon::now()->addDays(10)->format('dS M, Y (D)');
echo $futureDate;
In this code snippet, `Carbon::now()` gets the current date and time, `addDays(10)` adds 10 days to the current date, and `format('dS M, Y (D)')` formats the date in the desired format (e.g., 21st Jan, 2021 (Thu)).
Rate this post
5 of 5 based on 6484 votesComments