[resolved] Substr PHP Function with calendar? (3 posts)

  1. michaelmcguk
    Posted 8 years ago #


    Can anyone help me use the substr PHP function with the 'the_time' function.

    <div class="calendar">
    // $month = substr(the_time('S'(0,3)));
    <p class="month"><?php echo $month; ?> 
    <p class="date"><?php the_time('F j') ?>

    I had hoped the above would display the first three letters of the month, but seem to be getting errors :(

    Please help.

  2. Adam Brown
    Posted 8 years ago #

    the_time doesn't return the time, it echoes it. So that first line you've got commented out doesn't do anything. (Also, check your parentheses in the substr command.)

    You want get_the_time.

    $month = substr( get_the_time('S'), 0, 3 );

    Although this command doesn't make sense to me. Why not just use

    the_time('M'), which returns the three-letter abbreviation for the month?

  3. michaelmcguk
    Posted 8 years ago #

    Heh oh man do I full thick.
    Didn't realise you could do the_time('M')

    *hangs head in shame*

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.