Hello!
Why not having people post their own PHP functions here?
In my opinion, it would be a great benefit for us, beginners and pros,
because we would have plenty of code to study and to improve.
I'll start with a very simple function that outputs different
date formats I often use with dates taken from mysql (YYYY-MM-DD).
( the Japanese format won't correctly show up here, but you get the picture. )
function format_sqldate($date, $num) {
$method = array(
// ENGLISH FORMATS
"F d, Y", // [0] -> March 30, 2003
"l dS of F Y", // [1] -> Sunday 30th of March 2003
"D, d M Y", // [2] -> Sun, 30 Mar 2003
// FRENCH FORMATS
"d/m/Y", // [3] -> 30/03/2003
"d/m/y", // [4] -> 30/03/03
// JAPANESE FORMATS
"Y”N nŒŽ j“ú" // [5] -> 2003”N 3ŒŽ 30“ú
);
$date = explode("-", $date);
$date = date ($method[$num], mktime (0,0,0,$date[1],$date[2],$date[0]));
return $date;
}
Calling format_sqldate("2003-03-30", 1); will output Sunday 30th of March 2003.
Have a nice day!