Search
 
SCRIPT & CODE EXAMPLE
 

PHP

datetime validation in laravel

  return [
        'deadline' => 'required|date_format:Y-m-d H:i:s|after_or_equal:today',
    ];
Comment

Date time format for laravel validation

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

laravel date validation

'dob' => 'required|date_format:Y-m-d|after_or_equal:1920-01-01'
Comment

validate time in laravel

public function store(IlluminateHttpRequest $request)
{
    $this->validate($request, [
        'time_start' => 'date_format:H:i',
        'time_end' => 'date_format:H:i|after:time_start',
    ]);

    // do other stuff
}
Comment

datetime validation in laravel

  return [
        'deadline' => 'date_format:Y-m-d H:i:s'
    ];
Comment

Laravel validation date

'start_date' => 'required|date|after:tomorrow'
Comment

laravel validate date

 'day'            =>  'required|date',
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 request except multiple 
Php :: keep only n elements of array php 
Php :: wordpress escape string 
Php :: composer require no cache 
Php :: laravel make component inline 
Php :: make migration file in laravel 
Php :: Ways to write comments in PHP 
Php :: laravel button redirect 
Php :: php recursive function to build array 
Php :: laravel throw function 
Php :: contact form 7 remove p 
Php :: laravel denny request by ip 
Php :: remove first 4 characters in string php 
Php :: open json file php 
Php :: codeigniter 4 limit query 
Php :: php www to non www redirect 
Php :: insertgetid laravel 8 
Php :: laravel append 
Php :: filter_var filter_validate_url 
Php :: laravel auth 6 
Php :: php take picture with mobile camera 
Php :: laravel spatie asigne role 
Php :: how to run multiple seeder at a time in laravel 
Php :: check method in laravel 
Php :: php value to javascript variable laravel blade 
Php :: tableau aléatoire php 
Php :: use resource in laravel 8 
Php :: laravel is route name 
Php :: htmlspecialchars in php 
Php :: add custom helper laravel 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =