I am having a date format like this 30 Mar, 2018.
if i apply this 'start_date' => 'required|date validation rule, then The start date is not a valid date. error message is showing.
I have this code in model:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class Rates extends Model
{
protected $guarded = ['id'];
//protected $dateFormat = 'Y-m-d H:i:s';
protected $dates = [
'start_date',
'end_date'
];
public function setStartDateAttribute($value)
{
$this->attributes['start_date'] = Carbon::createFromFormat('d M, Y',$value);
}
public function setEndDateAttribute($value)
{
$this->attributes['end_date'] = Carbon::createFromFormat('d M, Y',$value);
}
}
For date input i am having,
<input class="form-control form_datetime_start valid" placeholder="Enter Start Date" name="start_date" type="text" value="30 Mar, 2018" aria-required="true" aria-invalid="false">
Even i tried to add this date_format:d M, Y rule, it also show The start date does not match the format d M. it is not considering , and Y.
Where do i miss? whats the problem?