Date() issue

Hi everyone - I’m hoping to find friendly help with a problem.

I started off with a form that used type=date this carries the date format to the DB as YYYY-MM-DD

i was using MM-DD-YYYY to comapre to DB dates but since then decided to change the compare same format

my code i’m using is

http://pastebin.com/s2B3QWS9

now the strange thing I can’t figure out is the date held in $today = 2014-03-11
the date held in the DB is showing the same 2014-03-11

but the query EVEN when ran though sql isn’t picking up anything as if the dates are not the same??

any suggestions?

First of all the format in MySQL timestamp is usually 0000-00-00 00:00:00, that is if you have it where you are using timestamp (which you should for it’s the easiest way of storing a date in MySQL). Then you can have any format you want when you pull it into php.

For example here’s a query from one of my scripts:

[php] $query = ’
SELECT
id,
username,
password,
DATE_FORMAT(date_added, “%e %M %Y”) as date_added
FROM users
WHERE
username = :username
';[/php]

This might help you out a little bit?

thanks I actually figured out that my query was wrong :frowning: but I did learn something about date function going through this :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service