• Resolved wilsontd

    (@wilsontd)


    Hello, I would like to be able to display at the top of a sidebar (in a text widget) a simple, single line that shows the live date and time.

    Wed 01-27 | 10:13 am

    I found some code, and managed to alter it and place it into my theme’s functions.php file without causing the theme to crash, I think. (Atahualpa theme)

    I don’t know whether the function should respond with “echo” or “return”

    — begin code snippet —–
    function tim_time {
    date_default_timezone_set(‘EST’);
    $tt = date(‘D m-d | h:i a’);
    echo $tt
    }

    OR

    function tim_time {
    date_default_timezone_set(‘EST’);
    $tt = date(‘D m-d | h:i a’);
    return $tt
    }
    — end code snippet —–

    But I have not figured out what syntax to put into the text widget to call this function.

    Also, I have no idea if it would show a live, running time– or just a ‘snapshot’ of whatever time it was when the function was “first” run.

    Can any kind soul take mercy on me and point me down the right path??

    THANK YOU!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Have live date and time updated in sidebar’ is closed to new replies.