-1

I am working with Php and right now i am getting date in following format

21 Dec 22  14:13

And i want to convert this date time into arabic language format,expected output is

 ٢١ ديسمبر ٢٢:١٣

Can we do this without "google api",How can i do this with php ?

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Maria
  • 47
  • 3

2 Answers2

1

PHP has everything you need for date formatting. Using IntlDateFormatter:

<?php
$date = '21 Dec 22  14:13';
$date_time = new DateTime($date);

$formatter = new IntlDateFormatter(
    'ar_DZ',
);
print $formatter->format($date_time);

Refer the IntlDateFormatter docs.

Jared
  • 1,294
  • 2
  • 8
  • 13
0

many of suggestion say you have to set setlocale but setlocale won't actually do any language translation for you but rather affects things like the formatting and comparator functionality. If you want localisation then you could try using IntlDateFormatter which may give you what you need.

Piyush Sapariya
  • 408
  • 3
  • 11