PHP date to MySQL date questions

I have a feeling that my date format is wrong… do i need to put am or pm after? Also… … do i need to store it in a string? Do i need to do…

$date='20180515 1:37:00 am';

Do I need to put am in capital letters?

I don’t see that in the context f the script you posted.
But if it is meant to be a datetime for the database the standard format is: YYYY-MM-DD HH:MM:SS using 24 hour clock, so no need for am/pm.

$date = '2018-05-15 01:37:00';

Thanks but do I need to assign it to a variable like what you did or can i just insert the ‘20180514 1:53:00’ directly? Do you need the -? I read somewhere that i could do… 20180514 or must it be… 2018-05-14?

The only code you posted in that question was assigning the date string to a variable, so I assume that was your intention.

I am baffled here because when I do this in my sql statement. .Insert into users (date) values (‘20180514 12:03:00’);

It doesn’t work … must i include the -?but the now () works well…i saw it somewhere on the web that it should work… do you always need to assing into a string?

I wonder if I can do something like this… now () + interval 1 month;

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.