Jump to content

date/time


karimali831

Recommended Posts

Hey,

 

I need help with date, I have stored dates in my table in this format:

i.e. 22.10.2011 but now use timestamp to store dates.

 

Problem is with this query the WHERE clause will find dates in the old format

and I want to change that to the new format.

 

	for($i = $count; $i > 0; $i--)
	{
		$day = date("d.m.Y", mktime(0, 0, 0, date("m"), date("d") - $i, date("Y")));
		$tmp = mysql_fetch_array(safe_query("SELECT count FROM ".PREFIX."counter_stats WHERE dates LIKE '%".$day."'"));
		$array[] = $tmp['count'] ? $tmp['count'] : 0;
	}

 

Am I making sense ?

Link to comment
https://forums.phpfreaks.com/topic/259163-datetime/
Share on other sites

You should be storing dates as date types into your database. Don't' make up a format or store them as PHP timestamp values. It will make yuur life more difficult int he long run. What type of field are you using now?

 

I changed data type to int(15) and it now stores timestamp but now need to change the WHERE clause to reflect to timestamp?

Link to comment
https://forums.phpfreaks.com/topic/259163-datetime/#findComment-1328597
Share on other sites

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.