I want to have a future timestamp for 'contests' that expire in my table. I can input the time without any problem except when I retrieve the input it doesn't seem to return me a carbon instance but merely a string with the time?
public function store(ContestRequest $request)
{
$input = Request::all();
// Set the 'owner' attribute to the name of the currently logged in user(obviously requires login)
$input['owner'] = Auth::user()->name;
// Set the enddate according to the weeks that the user selected with the input select
$weeks = Request::input('ends_at');
// Add the weeks to the current time to set the future expiration date
$input['ends_at'] = Carbon::now()->addWeeks($weeks);
Contest::create($input);
return redirect('contests');
}
This is what I am using to create a new contest, the timeformat is exactly the same in the table as the created_at and updated_at fields. They seem to return a Carbon instance when I try something like:
$contest->created_at->diffForHumans()
Why am I not getting a carbon instance returned?
My migration file looks like this:
$table->timestamps();
$table->timestamp('ends_at');