I often find it a headache to remember how best to be formatting datetime coming into and out of php/sql setups especially when outputting it via JSON to be rendered in javascript-based frontends.
This is how I do it.
datetime coming out of an SQL DB in the format of “2009-12-02 20:52:50”
1 2 3 4 |
// First get your date and pass it through the string to timeĀ function $datetime = strtotime($appraisal['appraisal_accepted']); // then format it in the standard php date fashion to something more pleasing to the eye - in this case "02/12/2009 8:52 PM" $appraisal_accepted = date("d/m/Y g:i A", $datetime); |