title: Symfony, how to get localized date
body: <p>most likely a silly question, but I do not see how to do.</p>
  
  <p>Within a controller, I need to use <code>$myObj-&gt;getData()-&gt;format('d-M-Y')</code>, and I wish to get a localized string too (in italian instead than in english).</p>
  
  <p>Within a twig template, I get it by   <code>{{ myobj.data|localizeddate('long', 'none', app.request.locale ) }}</code>, but I do not know a similar trick for the former case. </p>
  
  <hr>
  
  <p>Yes, I found how to do (thanks to  ccKep):</p>
  
  <p><code>$cal = IntlCalendar::fromDateTime($oldObj-&gt;getData()-&gt;format('d-M-Y')." Europe/Rome");</code></p>
  
  <p><code>$newObj-&gt;setField("my date is ". IntlDateFormatter::formatObject($cal, "d MMMM YYYY", 'it_IT')."");</code></p>