Welcome Guest, Not a member yet? Register   Sign In
Need Help With Formatting Date
#7

[eluser]jamesf[/eluser]
I create a small helper function that takes a MySQL date and outputs a date in the format i want...

Code:
function print_date($date) {
    // parse the date and time
    $year = substr($date, 0, 4);
    $year1 = substr($date, 2, 2);
    $month = substr($date, 5, 2);
    $day = substr($date, 8, 2);
    $hour = substr($date, 11,2);
    $min = substr($date, 14, 2);
return "{$hour}:{$min} - {$day}/{$month}/{$year}";
}

If your date was empty you could code up a small check e.g.

Code:
if(!empty($date)) {
return formatted_date;
} else {
return '';
}


Messages In This Thread
Need Help With Formatting Date - by El Forum - 03-21-2008, 03:30 PM
Need Help With Formatting Date - by El Forum - 03-21-2008, 04:24 PM
Need Help With Formatting Date - by El Forum - 03-21-2008, 04:36 PM
Need Help With Formatting Date - by El Forum - 03-21-2008, 04:48 PM
Need Help With Formatting Date - by El Forum - 03-24-2008, 08:43 PM
Need Help With Formatting Date - by El Forum - 03-26-2008, 06:01 AM
Need Help With Formatting Date - by El Forum - 03-26-2008, 09:02 AM
Need Help With Formatting Date - by El Forum - 03-26-2008, 09:10 AM
Need Help With Formatting Date - by El Forum - 03-26-2008, 09:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB