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