1
I want to type in the form the date in the format dd/mm/YYYY but search in the database in the format YYYY-mm-dd, please already tried everything, from a HELP Ai
1
I want to type in the form the date in the format dd/mm/YYYY but search in the database in the format YYYY-mm-dd, please already tried everything, from a HELP Ai
4
In Mysql there is the function STR_TO_DATE
, you receive as a parameter your string
date and converts to a valid date in the query SQL:
SELECT STR_TO_DATE("01/12/2018", '%d/%m/%Y')
Returns: 2018-12-01
2
$data = substr($obj->getData(), 8, 2);
$data .= "/";
$data .= substr($obj->getData(), 5, 2);
$data .= "/";
$data .= substr($obj->getData(), 0, 4);
you can use "substring" where in the above example "obj->getData()" is your date coming from the Database!
Browser other questions tagged php html mysql sql
You are not signed in. Login or sign up in order to post.
Use the class
DateTime
, has static functioncreateFromFormat
and the functionformat
to extract.– Roberto de Campos