Monday, November 4, 2013

MySql & PHP date format Part 1 -- DATE_FORMAT(), While loop, foreach()



  1. Convert Database date timestamp from ‘2013-10-10 01:25:39’to '10th October 2013 01:25 AM'.
  2. Use PHP WHILE loop and foreach() function
  3. Use MySQL DATE_FORMAT()
  4. SELECT DATE_FORMAT([1st parameter: variable login_date], 2nd parameter: the format string);
  5. SELECT DATE_FORMAT(login_date, ‘%D %M %Y %r‘)FROM login;
  6. MySql Date string format description, use % character
  • for example:
  %D = Day of Month with English Suffix
  %M = Name of Month
  %Y = 4 digits of numeric YEAR
  %r = AM/PM.

Source Link



No comments:

Post a Comment