Jump to content

current date is wrong


ramiwahdan

Recommended Posts

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 by ramiwahdan
Link to comment
Share on other sites

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 by Barand
  • Great Answer 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.