2

How can i convert a date in format yyyy-mm-dd to month-dd-yyyy in ro_RO locale ?

The date is outputed by <?php echo ($_GET["date"]);?>

CARASS
  • 245
  • 3
  • 16
  • @Ohgodwhy thanks. I have edit the title. Anyway i have checked that question beforem but i need to convert my date in the Romanian locale .is there a code to force the php to use the ro_RO locale ? – CARASS Mar 17 '15 at 20:18

1 Answers1

4

From PHP > 5.3 you can use IntlDateFormatter

$dt = new DateTime('2015-02-01'); // Date in yyyy-mm-dd format

$formatter = new IntlDateFormatter('ro_RO', IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); // Set locale name
$formatter->setPattern('MMMM dd yyyy'); // Return date in month-dd-yyyy format

echo $formatter->format($dt); // Format date

See it in action : http://3v4l.org/bQNah

BentoumiTech
  • 1,627
  • 14
  • 21