Question : Add date to MySQL

I have setup a cms form allowing my client to add a news item.

When the items info is sent to the database (ie title, copy, link, image) i need to add the date and then display it in on the website in the format DD-MM-YYYY.

How would i go about this?

Answer : Add date to MySQL

Hi
      
      While inserting Your date format should be YYYY-MM-DD H:i:s
      
      date('Y-m-d H:i:s') should be used for inserting.
      
      and while fetching You should use date_format function of mysql like below:
      
      SELECT DATE_FORMAT(date,'%D-%m-%Y') as date from table;
      
Hope this helps
Addy
Random Solutions  
 
programming4us programming4us