Ziaur Rahman Ziaur Rahman - 3 years ago 301
PHP Question

Make a Carbon object out of request input

How can I make use of the Carbon functionality with input from the request?

I am using a variable

which comes from my request:

$pre_Date = Input::get('Date');

Now I want to add a month with the variable
. I can use it with current date using
. How can i use addMonth() function for a variable $pre_Date which is not current date.

The format of $pre_Date variable is

Answer Source

You first create a Carbon object from your string.

$date = Carbon::createFromFormat('Y-m-d', $Date);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download