I am using javascript date picker which allows user to select date. However, I would also like to misinform the published date data before entering the database. I do not see any cleaning filter: http://us2.php.net/manual/en/filter.filters.sanitize.php
What would be the best method for disinfecting the date before entering the database?
This will be the original value from the message:
$datepick = $_POST['date']; // wich is 04/12/2014
Then I convert it to a database:
$date = date("Y-m-d", strtotime($datepick));
Thank!
If your date is like "03/02/2014", you can just clear the variable with a regex:
$date = preg_replace("([^0-9/])", "", $_POST['date']);
This allows only digits (0-9) and the slash fwd (/) to be used.
, :
:
DateTime::format DateTimeImmutable::format DateTimeInterface::format date_format() Date($format, $date_string)
This expression can be used to support the formats 12/12/2016 and 12-12-1993.
filter_var (preg_replace("([^0-9/] | [^0-9-])","",htmlentities($input)));
Source: https://habr.com/ru/post/1536298/More articles:Run pdb from the command line in an application packaged as a zip file? - pythonВызов подпрограмм perl из командной строки - subroutineWhy is this answer to the logical thingie expression correct? - boolean-logicHow to use memset function in two-dimensional array to initialize members in C? - cChange the color of the UITabBarItem icon in iOS 7.1 - iosHow do font identification algorithms work? - algorithmHow do you get a line to shoot in random directions with drawLine ()? - javaHow to check with SFINAE if a member exists without knowing the type of member? - c ++The setPromptText () function does not work initially with TextField - javafxGetting real depth from a mismatch map - opencvAll Articles