This class will be used to custom the SQL Datetime format in your style. This may very useful for web developers to make their work easy.

Class (Store as “sql.date.class.php“):

<?php

class FormatDate {

public function Date($SQLdate, $format) {

$maketime = strtotime($SQLdate);



return date($format,$maketime);

}
}

$dateobj = new FormatDate;

?>

Implementation (Store as “index.php“):

<?php

require_once “sql.date.class.php”;

echo $dateobj->Date(“2009-11-28 6:44:07″,”F j, Y, g:i a”); //Argument 1 is a SQL DATETIME format [Call your date format from SQL table], argument 2 is a format which u need.
echo “<br/>”;
echo $dateobj->Date(“2009-11-28 6:44:07″,”m.d.y”);
echo “<br/>”;
echo $dateobj->Date(“2009-11-28 6:44:07″,”h-i-s, j-m-y, it is w Day”);
echo “<br/>”;
echo $dateobj->Date(“2009-11-28 6:44:07″,’\i\t \i\s \t\h\e jS \d\a\y.’);

?>

In above class, you want to pass 2 arguments,

  1. First Argument will be date, which from SQL (DEFAULT SQL DATETIME FORMAT date(“Y-n-j g:i:s”)) table.
  2. Second Argument will be Date format which you need as output.

Once above passed arguments are correct, it will returns the date in Date Format, you needed. Download Source here [ ZIP Format ], [ RAR Format ] [Please Comment for updations]