dimensionav
asked on
How to show a formatted date?
I have a value from a field datetime in a mysql database and I want to show it formatted as a mm-dd-yyyy using php, how could be possible?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want to display date in different languages, you need to create your own function for that.
Eg:
and you have your $config prepared like this (in some config file)
and then the formatted date (where $timestamp is result of strtotime() with your date from DB)
Eg:
function getMonthText($month, $lang) {
global $config;
return $config['$lang']['month'][$month'];
}
and you have your $config prepared like this (in some config file)
//month text for english
$config['en']['month'][1] = 'January';
$config['en']['month'][2] = 'February';
$config['en']['month'][3] = 'March';
...
and then the formatted date (where $timestamp is result of strtotime() with your date from DB)
$date = getMonthText(date('j', $timestamp), 'en') .'-'. date ('d-Y', $timestamp);
ASKER