ramiwahdan Posted April 7, 2020 Share Posted April 7, 2020 (edited) Hi, when i try to insert to table date value it gives me wrong current date. $joindate = date('m-d-Y'); $sql = mysqli_query($con,"INSERT INTO staff (OracleID,StaffName,Des,joindate,username,password,isadmin) VALUES ('$oracleid','$name','$des','$joindate','$username', '$pass','$isadmin')"); i get this in the main page after making date("d-m-Y",strtotime(date)) 30-11--0001 why is that? Edited April 7, 2020 by ramiwahdan Quote Link to comment Share on other sites More sharing options...
Barand Posted April 7, 2020 Share Posted April 7, 2020 (edited) 5 minutes ago, ramiwahdan said: why is that? Because you should always work with yyyy-mm-dd format in your database (column type DATE) If you always want to insert the current date, use VALUES ('$oracleid','$name','$des',CURDATE(),'$username', '$pass','$isadmin') EDIT: and use prepared statements! Edited April 7, 2020 by Barand 1 Quote Link to comment Share on other sites More sharing options...
ramiwahdan Posted April 7, 2020 Author Share Posted April 7, 2020 thanks, it worked Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.