0

I have this situation:

$date = new Zend_Date();
$date->toString(Zend_Date::DATE_MEDIUM);
  • With 'it' locale this code outputs (e.g 04/mar/2013) instead of a dd/MM/yyyy format
  • With 'en' locale it outputs (e.g. Mar 4, 2013) instead of a MM/dd/yyyy format

In the Zend Framework documentation I can read at Date and Time Formats (format varies by locale)

Zend Date Constant

Updates:

/**
 * Convert a date from yyyy/mm/dd formatted by the locale setting
 *
 * @param date $dbindata
 * @param $format Zend_date format
 * @return date formatted by the locale setting
 */
static public function formatDateOut($dbindata, $format=Zend_Date::DATE_MEDIUM) {
    if (empty ( $dbindata ))
        return false;

    $locale = Zend_Registry::get('Zend_Locale');
    $date = new Zend_Date($dbindata, "yyyy-MM-dd HH:mm:ss", $locale);

    return $date->get($format);
}

Why?

Michelangelo
  • 1,398
  • 2
  • 14
  • 37

1 Answers1

0

I think you have to use the "get()" method of the Zend_Date object to get the Format you need.

$date = new Zend_Date();
echo $date->get(Zend_Date::DATE_MEDIUM);
opHASnoNAME
  • 20,224
  • 26
  • 98
  • 143
  • Hi AmeRie thanks for the reply but it doesn't work. I have added a simple method using your solution but it doesn't work. :( – Michelangelo Mar 05 '13 at 20:42