Jump to content

[SOLVED] MySQL DateTime -&- PHP Date()


hungryOrb

Recommended Posts

Hallo, trying to put a PHP Date() into my MySQL db DATETIME column, but ehh.. its saying:

 

Error: Incorrect datetime value: '' for column 'Started' at row 1

 

This makes me sad, is anyone knowing exactly what format I should use to store PHP's date function in my database properly?

 

I nub. Sari :(

Link to comment
Share on other sites

Yes, using the current server time.

As follows:

 

$started_query = mysql_query("SELECT Started FROM jobs
WHERE
`ID`='".$_POST["id"]."'");

IF (($_POST['started'] == "chk") && ($started_query == ""))
	{ 
	$started_store = date('Y-m-d H:i:s');
	}

$sql="UPDATE jobs SET `Started`='".$started_store."'
WHERE
`ID`='".$_POST["id"]."'";

 

Just want to put it straight into a var, then directly into the database.. :'(

ty for help though ;]

Link to comment
Share on other sites

hm, thanks. Not sure If I wanna give up on my DATETIME field type atm!

BUT-! hmm, what do you mean by the field being seT? You mean throw some generic values in the appropriate format in there to simply replace with UPDATE? If so, then my IF statement becomes worthless :(

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.