h1mal
3/12/2012 - 1:26 PM

PHP MySQL Date Format for automatically timestamped table columns

PHP MySQL Date Format for automatically timestamped table columns

<?php
// The data which is stored in the db as YYYY-MM-DD H:i:s = php date();
$data_from_db = strtotime('2012-03-12 14:26:03');

// Formatting the data
// Configurable. See the strftime() function entry in php.net
$format_data_output = strftime('%d.%m.%Y, %H:%M:%S', $data_from_db);

// Echo the formatted data
echo $format_data_output;

// If useful: give a smile ;-)
?>