Jump to content

Create a date string (dd/mm/yyy) from table with dd, mm and yyyy separated


Recommended Posts

Guys,

I am trying to create a date string of dd/mm/yyyy from a table that has the dd, mm and yyyy info in different columns. My problem is how to get the / in the string without getting errors.

So far I have the data query working fine, that is not the problem and I can echo as follows:

echo ($row->day);

echo ($row->month);

echo ($row->year);

 

and get for example 12082009 so the data access side of things is fine.

Now, how do I get this data into a string that, if echoed, will give me 12/08/2009 instead?

 

I need to use this string to test against another table that has the date in the format of dd/mm/yyyy in a single column.

 

Looking forward to your responses

Hi

 

Use mysql CONCAT() function to retrieve the data already formated.

You should really fix table in order to have only 1 column of type date and remove the other 3 columns.

 

In php the dot character is the concatenation symbol. example: echo 'Foo'.'-'.'bar';  //prints "Foo-bar"

 

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.