Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Date time format for laravel validation

 $request->validate([
        'start_date' => 'date_format:d/m/Y',
        'end_date' => 'date_format:d/m/Y'
    ]);
Comment

in laravel date duration validation rule

[
  'from' =>  ['required', 'date_format:Y-m-d', 'before_or_equal:to'],
  'to'  => ['required', 'date_format:Y-m-d']
]
//@sujay
Comment

laravel validation date time format

public function validateDate($attribute, $value)
 {
   if ($value instanceof DateTimeInterface) {
     return true;
   }

   if ((! is_string($value) && ! is_numeric($value)) || strtotime($value) === false) {
     return false;
   }

   $date = date_parse($value);

   return checkdate($date['month'], $date['day'], $date['year']);
 }

############## OR ###################

public function validateDateFormat($attribute, $value, $parameters)
{
  if (! is_string($value) && ! is_numeric($value)) {
    return false;
  }

  $format = $parameters[0];

  $date = DateTime::createFromFormat('!'.$format, $value);

  return $date && $date->format($format) == $value;
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel checking if a record exists 
Php :: php date set utc 
Php :: artisan make migration with model 
Php :: woocommerce cart length button shortcode 
Php :: mcrypt php extension required 
Php :: laravel delete relationship data 
Php :: blade select selected 
Php :: PHP Time Limit: 
Php :: PHP MySQL Delete Data 
Php :: how to run multiple seeder at a time in laravel 
Php :: laravel eloquent get all 
Php :: laravel make model all with resources api 
Php :: failed to open stream permission denied in php 
Php :: php read text file into array 
Php :: php sort hight to low 
Php :: Reset Admin password in Magento 2 
Php :: php superglobals 
Php :: get next month first day php 
Php :: php encrypt decrypt url parameters 
Php :: php string left 10 characters 
Php :: doctrine orm get all 
Php :: why does php syntax doesnt work in my html 
Php :: Day of Week Using carbon library 
Php :: how to clear session in laravel 
Php :: __dir__ in php 
Php :: how can set defult value for yield in laravel 
Php :: how to log object laravel logger 
Php :: laravel log level 
Php :: shortcode php wordpress 
Php :: docker php 7.2 add ext-mongodb 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =