I want display my post time at jalali date php format

437 Views Asked by At

here is jdate library jdate

my format.php file

<?php
/**
*Format Class
*/
class Format{
    public function formatDate($date){
        return date('F j, Y, g:i a', strtotime($date));
    }

    public function textShorten($text, $limit = 400){
        $text = $text. "";
        $text = substr($text, 0, $limit);
        $text = substr($text, 0, strrpos($text, ' '));
        $text = $text. "";
        return $text;
    }
}
?>

and my post date code

<h6><?php echo $fm->formatDate($result['date']); ?>, by<a href="#"><?php echo $result['author']; ?></a></h6>

how can I use jdate instead of gregorian time .

1

There are 1 best solutions below

4
On

you should include the jdf.php file, then just use jdate instead of date

<?php
/**
*Format Class
*/
include_once('jdf.php');
class Format{
  public function formatDate($date){
     return jdate('F j, Y, g:i a', strtotime($date));
  }

  public function textShorten($text, $limit = 400){
    $text = $text. "";
    $text = substr($text, 0, $limit);
    $text = substr($text, 0, strrpos($text, ' '));
    $text = $text. "";
    return $text;
  }
}
?>

for more information and help, refer to this link