Page 1 of 1
Date Formating
Posted: Tue Jan 26, 2010 2:12 am
by shahzad429
I am storing date as 2010-01-26 in Mysql
But i want to display it as November 29th, 2009 to the user
how to format the date??
thanks in advance
Re: Date Formating
Posted: Tue Jan 26, 2010 2:41 am
by requinix
Format a date in MySQL?
Format a
date in
MySQL?
http://www.google.com/search?q=format+date+mysql
Re: Date Formating
Posted: Wed Jan 27, 2010 12:37 pm
by social_experiment
Store the date as an integer inside the database ( as received when you use the time() function ) then you can manipulate it in whichever way you want using the date() function. The code that will give you the format you are looking for ( php format not mySQL format ) is :
Code: Select all
<?php
date('F jS, Y', $valueRetrievedFromDb);
?>
Re: Date Formating
Posted: Wed Jan 27, 2010 1:03 pm
by requinix
For that matter,
Store the date as a DATE inside the database ( as received when you use the date() function ) then you can manipulate it in whichever way you want using the DATE_FORMAT() function. The code that will give you the format you are looking for ( MySQL format not PHP format ) is :
Code: Select all
<?php
"SELECT DATE_FORMAT(fieldFromTable, '%M %D, %Y')..."
?>