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

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 datetime with datetime-local

$this->validate($request, ['my_date' => 'date_format:Y-m-dTH:i']);
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 :: concat in laravel 8 
Php :: laravel loop through collection 
Php :: how to get all roles in wordpress 
Php :: Carbon Format date with timezone in views Laravel 
Php :: how to get video duration in php 
Php :: laravel relationship with for single data 
Php :: laravel vue csrf 
Php :: array filter use key 
Php :: woocommerce action order complete 
Php :: laravel add timestamps to existing table 
Php :: Limit Product Name in Magento2 
Php :: phpspreadsheet edit excel file 
Php :: swich in php 
Php :: add another field in existing migration laravel 
Php :: php chunk array 
Php :: php parse html 
Php :: php pass variable to anonymous function 
Php :: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/Cellar/composer/1.9.1/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223 mac 
Php :: php remove object from array by property 
Php :: PHP strrev — Reverse a string 
Php :: how to disable register route in laravel 
Php :: composer 
Php :: php array join 
Php :: raw query in laravel with parameters 
Php :: php time difference in hours 
Php :: how to pass variable in inside function into where in laravel 
Php :: php session get data 
Php :: wc order details 
Php :: php remove prefix from string 
Php :: php hash password 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =