/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Conversion $var_day = $date_array[0]; //day seqment $var_month = $date_array[1]; //month segment $var_year = $date_array[2]; //year segment $new_date_format = "$var_year-$var_day-$var_month"; // join them together Possibly a more MySQL friendly format in some circumstances. Change period-separated to slash-separated or vice versa (and reverse order) /** * @param string $date (d.m.y, y-m-d, y/m/d) * @return string|bol */ function convertDate($date) { // EN-Date to GE-Date $date = $date[2].".".$date[1].".".$date[0]; return $date; } // GE-Date to EN-Date $date = $date[2]."-".$date[1]."-".$date[0]; return $date; } return false; }
URL: http://css-tricks.com/snippets/php/change-date-from-ddmmyyyy-to-yyyy-dd-mm/