Date field issue
Solved
Jeremd89
Posted messages
12
Status
Member
-
jordane45 Posted messages 30426 Registration date Status Moderator Last intervention -
jordane45 Posted messages 30426 Registration date Status Moderator Last intervention -
Hello everyone,
After hours on the internet searching for my answer, I finally decide to ask my question directly.
I invite the users of my site, in a form, to indicate a certain date. This field specifies a format like 20/08/2018. However, in my database, the format is 2018-08-20.
What should I do?
Thank you in advance.
After hours on the internet searching for my answer, I finally decide to ask my question directly.
I invite the users of my site, in a form, to indicate a certain date. This field specifies a format like 20/08/2018. However, in my database, the format is 2018-08-20.
What should I do?
Thank you in advance.
1 answer
Hello
You just need to reformat the date into a timestamp so that it can be correctly inserted into your database...
For example:
Or
Alternatively, in your SQL query, it should also be possible to use STR_TO_DATE:
--
Best regards,
Jordane
You just need to reformat the date into a timestamp so that it can be correctly inserted into your database...
For example:
$date="20/08/2018"; $date = explode("/", $date); $newsdate=$date[2].'-'.$date[1].'-'.$date[0]; Or
$date="20/08/2018"; $newdate = date('Y-m-d', strtotime($date)); Alternatively, in your SQL query, it should also be possible to use STR_TO_DATE:
STR_TO_DATE('20/08/2018', '%d/%m/%Y') --
Best regards,
Jordane
Thank you for your response, I understand where you're coming from, I will try that right now!
thank you for your help!