skip to Main Content

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 ?

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search