0

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 .

Ali
  • 626
  • 1
  • 11
  • 29
Saeid
  • 9
  • 2
  • _Small Point_ `$text = $text. "";` does nothing but use cpu cycles – RiggsFolly Aug 18 '18 at 14:02
  • 1
    _Second Small Point_ **No sensible SO user** is going to download unknown zip files in order to answer a question. The risk is just to high.. Please post code as text – RiggsFolly Aug 18 '18 at 14:04

1 Answers1

1

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

Ali
  • 626
  • 1
  • 11
  • 29
  • ali insert ur codes , but show wrong year-->1348 with this error Warning: A non-numeric value encountered in C:\xampp\htdocs\helpers\jdf.php on line 17 – Saeid Aug 18 '18 at 19:04
  • First comment: Does your date is in right format? see this links: https://stackoverflow.com/questions/50174713 https://stackoverflow.com/questions/2891937 – Ali Aug 19 '18 at 05:53
  • 2nd comment : maybe you have forgot to include jdf.php in your index.php or maybe you have forgot to copy that file in the index directory – Ali Aug 19 '18 at 05:55
  • @Saeid, your welcome. so you can accept and/or vote up it. let me know , if the answer need to be edited. – Ali Aug 24 '18 at 15:47