• Unfortunately the only both Jalali Date plugins (“Parsi Date” and “WP-Farsi”) has conflict with “Yoast Seo plugin” and some others which uses DATE_W3C format.

    The issue is converting Gregorian Date to Jalali Date in headers Meta Tags, which is must be stayed in Gregorian date.

    <meta property="article:published_time" content="????-??-??\??:??:??" />
    <meta property="article:modified_time" content="????-??-??\??:??:??" />
    <meta property="og:updated_time" content="????-??-??\??:??:??" />

    For fixing this issue you must add the following code in the “includes/parsidate.php”:

    1- Find the persian_date function.
    2- At the beginning of this function add the following code:

    if ( $format == 'Y-m-d\TH:i:sP' ) {
        $format = 'c';
    }

    This code would convert DATE_W3C format to the ‘c’ format.

    3- After that, in switch/case loop, remove the following line after case ‘c’:

    
    $out = $date['year'] . '/' . $date['mon'] . '/' . $date['mday'] . ' ' . $date['hours'] . ':' . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':' . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']);
    

    4- Then add the following code instead of removed line:

    
    list($eng_date['year'], $eng_date['mon'], $eng_date['mday']) = self::persian_to_gregorian( $date['year'], $date['mon'], $date['mday'] );
    $out = $eng_date['year'] . '-' . $eng_date['mon'] . '-' . $eng_date['mday'] . 'T' . $date['hours'] . ':' . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':' . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']) . '+04:30';
    $lang = 'eng';
    

    5- One more update is to find the persian_to_gregorian function, and change the last return line to the following code:

    return array($gy, strlen($gm) == 1 ? '0' . $gm : $gm, strlen($gd) == 1 ? '0' . $gd : $gd);

    This editing is on ParsiDate plugin (ver.2.3.4). I hope it solved in the upcomming version.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Conflict with DATE_W3C format’ is closed to new replies.