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

validate year laravel

'year' => 'required|digits:4|integer|min:1900|max:'.(date('Y')+1),
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 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 :: php return new object 
Php :: laravel groupby and latest 
Php :: check mobile or email in laravel 
Php :: hide add new link on cpt page 
Php :: get nearby from longitude and latitude in laravel 
Php :: php curl add user agent 
Php :: run schedule laravel 
Php :: php foreac 
Php :: Remove last symbol from string 
Php :: explode segments url php 
Php :: php new line 
Php :: laravel when condition 
Php :: check if value change laravel 
Php :: carbon greater than 
Php :: jQuery is not defined load-scripts.php 
Php :: woocommerce after order been placed hook 
Php :: CSV File Read using PHP fgetcsv() 
Php :: how to solve php mysqli_query function problem does not execute 
Php :: php-fpm docker 
Php :: livewire datatable Delete column momentarily triggering confirmation dialog of last row during page load 
Php :: Eloquent where date methods 
Php :: cakephp 4 change layout view in a method 
Php :: php check if parameter exists in url 
Php :: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) laravel 
Php :: date_default_timezone_set php bangladesh 
Php :: php replace br 
Php :: array sort php 
Php :: php json data to array 
Php :: send json reponse php 
Php :: ci constructor 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =