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

laravel validation time hours minutes format

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 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 :: install phpmyadmin ubuntu 
Php :: laravel check auth 
Php :: superglobal php 
Php :: get current date laravel 
Php :: php compare string 
Php :: remove add media button wordpress editor 
Php :: laravel inline if 
Php :: php mysql datetime 
Php :: select case default php 
Php :: for loop php 
Php :: last login date time in wordpress 
Php :: php sha256 example 
Php :: show php erros 
Php :: symfony clear cache 
Php :: first day of month php 
Php :: faker image laravel 
Php :: Carbon add 3 hours 
Php :: php remove characters not numbers or letters 
Php :: pdo connexion 
Php :: delete cache laravel 
Php :: run laravel localhost network 
Php :: carbon now format 
Php :: get hours difference between two dates in php 
Php :: whereyear laravel 
Php :: twig symfony get route 
Php :: get last two numbers from int php 
Php :: center mode slick slider 
Php :: doctrine php driver execption 
Php :: add action wp_footer 
Php :: check if value exists in object php 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =