Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #771721

    Hello,

    i want to get the day and time from the post and to set it inside the post like text or code.

    e.g. i created a post with name test, i set inside that some texts and above of texts i want to refer the day and time of post published. How can do that?

    See the link *. I want to show the day and time automatically. Now i insert the day and time manually.

    Thank you

    #771728

    Hi Designweb!

    Please add following code to Functions.php file in Appearance > Editor

    
    
    function av_get_post_date(){
    
        ob_start();
        $output = the_date();
        $output = ob_get_clean();
        return $output;
    }
    
    add_shortcode( 'post_date', 'av_get_post_date' );

    Then use [post_date] shortcode to echo the date of your posts

    Cheers!
    Yigit

    #771762

    Hello Yigit,

    that works like a charm. Also, i want to show and the name of the date like Monday 03.04.2017 , Tuesday 04.04.2017… etc

    How can do that?

    Thank you

    #771767

    Hi!

    Please change the code to following one

    function av_get_post_date(){
    
        ob_start();
        $output = the_date('l d.m.Y');
        $output = ob_get_clean();
        return $output;
    }
    
    add_shortcode( 'post_date', 'av_get_post_date' );

    Best regards,
    Yigit

    #771776

    Hello Yigit,

    great answer! That work fine!

    Thank you very much

    #771777

    Hi!

    You are welcome!

    For your information, you can take a look at Enfold documentation here – http://kriesi.at/documentation/enfold/
    And if there are features that you wish Enfold had, you can request them and vote the requested ones here – https://kriesi.at/support/enfold-feature-requests/
    For any other questions or issues, feel free to post them here on the forum and we will gladly try to help you :)

    Best regards,
    Yigit

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Php code to get Day and Time inside the post’ is closed to new replies.