I need to enter dates and time(input as strings) into my database but there’s no change (remains as 0000-00-00 for the date and 00:00:00 for the time). I know I’m supposed to use DateTime::createFromFormat() but I’m not sure how to go about it. Please be patient and explain to me how I’m supposed to go about it and what is happening in each step and if I want to return the date from the database on later on, how will I go about it? I’m using $date and $starttime , $endtime.
I need to enter dates and time(input as strings) into my database but there’s
Share
While inserting, use
STR_TO_DATEto convert your String date toDateorDATETIMEbased on the format as :Similarly use
DATE_FORMATduring retrieval to convert into string of desired format as:Let me know, if you need further explanation.