title: Converting a date from a calendar type to another type
body: <p>I need a function to convert a date in Persian calendar to it counterpart Gregorian date. I wrote following function following Example #3 of <a href="http://www.php.net/manual/en/intldateformatter.setcalendar.php" rel="nofollow">this page</a>. Unfortunately, it does work? What is wrong with it? what is the correct method to do that using the Intl extension? </p>
  
  <pre><code>function convert($time, $fromCalendar = 'gregorian', $toCalender = 'persian', $fromFormat = 'yyyy-MM-dd HH:mm:ss',
                   $toFormat = 'yyyy-MM-dd HH:mm:ss', $timezone = null, $local = 'fa_IR')
  {
      $formatter = IntlDateFormatter::create($local . '@calendar:' . $fromCalendar, null, null, $timezone, null, $fromFormat);
      $formatter-&gt;setCalendar(IntlCalendar::createInstance(null, $local . '@calendar:' . $toCalender));
      $output = $formatter-&gt;format($formatter-&gt;parse($time));
      if ($output) return $output;
      return $formatter-&gt;getErrorMessage();
  }
  </code></pre>
  
  <p>A good introduction of Intl can be found here: <a href="http://devzone.zend.com/1500/internationalization-in-php-53/" rel="nofollow">http://devzone.zend.com/1500/internationalization-in-php-53/</a></p>