Perspolis
Perspolis

Reputation: 862

PHP not show print date class

I have this class for convert date to arabic date and show/print date in arabic.

PHP Arabic class HERE:

for print arabic date:

<?PHP $arabicdate = new ArabicTools;
echo $arabicdate->arabicDate('Y',1445299200);
?> 

But this code print this output: Y

How do can i fix this problem?!

DEMO

Upvotes: 1

Views: 47

Answers (1)

Armfoot
Armfoot

Reputation: 4921

I did a global check and I believe it's related to what you do at the end in the arabicDate($format, $timestamp):

if ($type == "ah:") $date = $format . " AH";
  else $date = $format;

So what you pass as a parameter to that function is returned by:

if ($use_span) return '<span dir="rtl" lang="ar-sa">' . $date . '</span>';
  else return $date;

Therefore you get the Y because it never enters the code block that you have inside if ($type == 'hj:' || $type == "ah:") (since $type = substr($format, 0, 3) and $format is just Y), so the $format is never changed besides the $format = trim($format) at the beginning.

Try instead echo $arabicdate->arabicDate('hj:',1445299200); (or using 'ah:') and you may get a more interesting result...

Upvotes: 1

Related Questions