I have a forum in PHP which takes a date like in the form
dd/mm/yyyy hh:mm:ss. However, I need to insert it for SQL as a DATETIME in the format as yyyy-mm-dd hh:mm:ss. How can I convert this data?
I have a forum in PHP which takes a date like in the form
Share
Your date time format is wrong:
dd/mm/yyyy hh:mm:ss. Probably you meand/m/Y H:i:sIf you have 5.3+ version there is safe way to convert the date time into another format. Here’s an example:
or if you like more procedural way:
Be careful with previous suggestions. Some are completely wrong and others could lead to errors.