Saving the_time to a variable (3 posts)

  1. Naax
    Posted 7 years ago #

    Hello all, first few days working with WP and I have to say I'm impressed. Such a simple templating system, I love it.

    I am having one issue right now. I would like to save the year a post was created to a variable that i can loop through the string and perform some manipulations.

    the_time seems to have the echo built in, so I'm wondering if there is a function built in I can use that will do something like this:

    $year = the_time('Y');

    Seems simple enough, thanks in advance!

  2. Try using this function:

    <?php get_the_time('format'); ?>

    ... and you can read more about it here: http://codex.wordpress.org/Function_Reference/get_the_time

    Hope that helps some ...

  3. bourkela
    Posted 6 years ago #

    Thank you! This was helpful.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.