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
https://forums.phpfreaks.com/topic/71814-solved-mysql-datetime-php-date/
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 ;]

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 :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.