我想以jalali日期php格式显示我的发帖时间

时间:2018-08-18 14:00:33

标签: php jalali-calendar

这是jdate库jdate

我的format.php文件

<?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;
    }
}
?>

和我的职务日期代码

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

如何使用jdate而不是格里高利时间。

1 个答案:

答案 0 :(得分:0)

您应该包含jdf.php文件,然后仅使用jdate代替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;
  }
}
?>

有关更多信息和帮助,请参阅this link