• Resolved iamludo

    (@iamludo)


    Hi team

    I would like to use the shortcode [wpdts-day-of-year] to display the day of the year number. However, I need a 3 digits number (008 or 076…) and this shortcode doesn’t have the leading zero(s) functionality.
    What do I need to do to display a 3 digits day of the year number and/or can I use WP Date and Time Shortcode to achiver that ?

    Thanks for the help.

Viewing 1 replies (of 1 total)
  • Plugin Author Denra.com

    (@denra)

    Hello @iamludo,

    The plugin currently does not offer this functionality but here is some source code that can help you. Just place it in your functions.php of the child theme and then use [wpdts-day-of-year-lz] as a shortcode in your text.

    // Shortcode for day of year year with leading zeros.
    add_shortcode( 'wpdts-day-of-year-lz', 'wpdts_day_of_year_lz' );
    function wpdts_day_of_year_lz( $atts ) {
         return sprintf( '%03d', intval( date( 'z', current_time( 'timestamp' ) ) ) + 1 );
    }

    Thank you for trying our plugin.

Viewing 1 replies (of 1 total)
  • The topic ‘Day of the Year with leading zero(s)’ is closed to new replies.