PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, February 10, 2022

[FIXED] Validate datetime-local input

 February 10, 2022     laravel, laravel-5, laravel-5.4, laravel-validation     No comments   

Issue

According to MDN, I should use datetime-local type for a date and a time input:

<input type="datetime-local">

I can validate a date in laravel with this code (in a controller):

$this->validate($request, ['my_date' => 'required|date']);

But is there a way to validate a datetime-local?


Solution

You can use date_format:format or date to validate. All date validation is performed by php strtotime

The best way to know for sure is to test this. Create your rules function in the controller and test, that way you know for sure for your laravel version and your php version as you don't mention that information.



Answered By - Glenn Plas
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing