Store date from datepicker into db I'm trying to store a date from jquery datepicker into the db using laravel ofc.
Also I need to check if the selected date is the current date.
You must be more precise
If you want to check if datepickers date is current (i assume today)
Carbon::parse($request->get('datepicker')->eq(Carbon::today()))
It seems the date format from the datepicker is not the same as the carbon instance.
I need the carbon instace to be in this format "yy-mm-dd", to work.
I've done it. Is there a way to check the date with validation rules ?
@Cosmin89
$formatOfDateYouWant = Carbon::parse($request->get('datepicker')
->eq(Carbon::today()))->format('yy-mm-dd')
If I use in the custom validation rules "date_format:yy-mm-dd" the same format as the datepicker format, it says that "does not match the format yy-mm-dd. "
What format should I use then ?
Dont know what plugin you use but there is a possibility to customize format
var date = $('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' }).val();
I've set it to "yy-mm-dd", in the datepicker and validation rule. No matter what format I choose it seems wrong.
dd($request->get('datepicker')); and see what you get
Please sign in or create an account to participate in this conversation.