• Resolved Anonymous User 18794746

    (@anonymized-18794746)


    I am using a function to convert all the Latin numerals on my site to Devanagari ones :

    function DevNumDate ($text) {
    $text = str_replace('1', '१', $text);
    $text = str_replace('2', '२', $text);
    $text = str_replace('3', '३', $text);
    $text = str_replace('4', '४', $text);
    $text = str_replace('5', '५', $text);
    $text = str_replace('6', '६', $text);
    $text = str_replace('7', '७', $text);
    $text = str_replace('8', '८', $text);
    $text = str_replace('9', '९', $text);
    $text = str_replace('0', '०', $text); 
    return $text;
    }
    
    add_filter('get_date', 'DevNumDate');
    add_filter('get_the_date', 'DevNumDate');
    add_filter('get_the_time', 'DevNumDate');

    But, this gives me too much warnings like :

    Warning: gmdate() expects parameter 2 to be int, string given in /home/user/domains/<domain>/public_html/wp-admin/includes/dashboard.php on line 977
    Warning: gmdate() expects parameter 2 to be int, string given in /home/user/domains/<domain>/public_html/wp-admin/includes/dashboard.php on line 975
    Warning: gmdate() expects parameter 2 to be int, string given in /home/user/domains/<domain>/public_html/wp-admin/includes/dashboard.php on line 973

    How can I nuetralize those warnings ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @abhidesh128 – You can try to set priority of add_filter lower.

    add_filter('get_date', 'DevNumDate', 1);
    add_filter('get_the_date', 'DevNumDate', 1);
    add_filter('get_the_time', 'DevNumDate', 1);
    • This reply was modified 2 years, 9 months ago by hiyottaunits.
    Thread Starter Anonymous User 18794746

    (@anonymized-18794746)

    Thanks @hiyottaunits …!

    Unfortunately, even after setting priority, the warnings didn’t stopped…

    When I replace the ‘get’ functions with ‘the’ functions, the warnings vanish, but the numerals on the posts are not replaced.

    It seams the date format is not accepted by some functions due to the Devanagari. Can you deactivate all plugins and try that code again?

    Thread Starter Anonymous User 18794746

    (@anonymized-18794746)

    Hi @hiyottaunits..! I was able to successfully solve this issue..!

    I first checked out the source code of my page builder modules, and found that only the_time & get_the_time are being used. So I modified the code accordingly. Also, per my requirement, I just wanted to replace numerals on frontend, not on administrative area.

    So, I installed Code Snippets plugin, removed the function from functions.php and added it as a snippet only to be run on frontend. All warnings were vanished..!

    Thank you for your support..!

    Thread Starter Anonymous User 18794746

    (@anonymized-18794746)

    Marking this as resolved. Thank you..!

    Great to know this issue resolved. Thanks 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘gmdate() warnings after trying to set up a numeral converting function’ is closed to new replies.