Support » How-To and Troubleshooting » [Resolved] Substr PHP Function with calendar?

[Resolved] Substr PHP Function with calendar?

  • Hi,

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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?

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

    *hangs head in shame*

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Substr PHP Function with calendar?’ is closed to new replies.