Search code examples
phpwordpressdatewoocommercedate-format

Customize date_i18n format in Woocommerce


I want to change the format of the date from '15 June 2018 to 15-06-2018' because i have a multilingual website and my code returns date only in English. here is the code :

$expiry = date_i18n(wc_date_format(), strtotime('+'.$expiry.' days'));

this code returns '15 June 2018' i don't know if we can add something like :

wc_date_format(d, m, y)

Thanks


Solution

  • The correct way tp get what you expect is replacing wc_date_format() by 'd-m-Y' in your code:

    $expiry = date_i18n( 'd-m-Y', strtotime('+'.$expiry.' days') );
    

    This time you will get 15-06-2018 instead of 15 June 2018.