PHP Date population trouble


I am trying to get the date to display correctly in PHPMYAdmin as the correct date but all it shows is 0000-00-00. I know for sure there is a character off and it needs changed to something but I cannot figure it out for the life of me.

Here is the code and can someone show me why it wont work. What is wrong?? In this statement, why would it show the Date as 0000-00-00 instead of an actual date. For example it should read 2019-05-21 for example.

$sql=“UPDATE CreditTracker SET Approve=”$Approve",ClassWkshp=“ClassWkshp”,Sponsor="$Sponsor",Type="$Type",HrsUnits=“HrsUnits”,Date="$Date",$DateApproved WHERE idnum="$idnum"";

Why cant i get my date to show??


Try this date_default_timezone_set(‘Europe/Paris’);
$date = date(“d F Y H:i:s”);


And in my sql change row date in longtext,


Yeah, no. That is not how you store dates.

1 Like

It’s current date,you insert into mysql


If you want just date,you put without H:i:s


It seems like when I upgraded from php5 to php7 something broke. Seems tied to a single character.


You need to run $sql,put mysqli_query($db,“Update your code here”);


What does adding var_dump($Date) right before the sql statement show and where exactly is the $Date variable coming from?

Note: you should not put external/unknown data directly into an sql query statement. Use prepared queries instead. This actually simplifies your code, provided you are using the php PDO extension (you no longer need a bunch of different logic to make it safe to put all the different kinds of values into an sql query statement and it simplifies the sql query syntax.)


That will show you exactly what is in the database and has nothing to do with PHP whatsoever.

You should be storing the date how the database expects it, and only change the formatting based on the view of the page that needs it.


Great Gatsby this is incorrect. If this is what you should do, then please explain why there are date types?