Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.4k views
in Plugins by
edited by

How can I add time and date to my website?

Q2A version: 1.6.3
by
In front of search box. Thanks

3 Answers

0 votes
by
edited by

Well, you have a custom theme in there so you only know how to do that :)

Anyway, I can guess you've modified the Snow theme, based on the look and feel of the search bar...

I can blindy advice you to try this:

1. Open /qa-theme/<your-theme>/qa-theme.php

2. Look for function search()

3. If it is not present (it shouldn't, as it is not present in Snow theme), then just add this function to the file:

public function search() {
    $search = $this->content['search'];
    $this->output(
        '<div class="qa-search">',
        '<form '.$search['form_tags'].'>',
        @$search['form_extra']
    );
    $this->search_field($search);
    $this->search_button($search);
    $this->output(
        '<span style="color: white">',
        date('Y-m-d H:i:s'),
        '</span>',
        '</form>',
        '</div>'
    );
}
 
4. If it is present you'll have to merge the function with the one I'm giving you
 
Note the inline styling is just for make things easy for you. Ideally, you would apply or CSS rules to your css file.
Also, for date format you should take a look at this: http://php.net/manual/en/function.date.php
 
EDIT:
Previous solution shold work in Snow theme. After taking a look at your site I can confirm you've modified it so much it is not Snow theme anymore. Without knowing your (new) theme it is very hard for me to guess. My closes try would be this:
 
1. Remove changes applied in the previous part of the answer
 
2. Locate again your qa-theme.php file
 
3. Edit the body_header function so that it looks like this:
 
public function body_header() {
    $this->output('<div id="qa-login-bar"><div id="qa-login-group">');
    $this->nav_user_search();
    $this->output(
        '<span class="qa-date-and-time">',
        date('Y-m-d'),
        '<br/>',
        date('H:i:s'),
        '</span>'
    );
    $this->output('</div></div>');
}
 
4. Edit your qa-styles.css file and add this to the bottom:
 
span.qa-date-and-time {
    color: white;
    float: left;
    line-height: 1.2;
    margin-left: 10px;
}

Maybe you're lucky and this fixes it.

by
edited by
Thanks pupi.
I added the result in another answer.
Thank you for your help.
by
Thank you Pupi. But I got this error:
 Fatal error: Cannot redeclare qa_html_theme::body_header() in /home/.../public_html/.../qa-theme/Snow/qa-theme.php on line 96
by
Well, step #3 states: "Edit the body_header function so that it looks like this:"... you must have added a new function.
by
Pupi1985: Thanks. Could you please tell me how can I add date and time to the rear of site logo?
0 votes
by

Thanks pupi.

But it is like this:

 

0 votes
by

Could you please tell me how can I add date and time to the rear of site logo?

1. Open /qa-theme/<your-theme>/qa-theme.php

2. Add this function (if you're using a variation of the Snow theme, it shouldn't be there)

public function logo() {
    $this->output(
        '<div class="qa-logo">',
            '<span style="font-size: 35%">',
                date('Y-m-d H:i:s'),
            '</span>',
            $this->content['logo'],
        '</div>'
    );
}

3. It is not clear to me if you want it to the left or to the right, and rear in an RTL theme really confuses me :) In order to change the location just move the line $this->content['logo'], immediately before the line that starts with '<span style="...

4. If you want to chante the size of the text then change the numer 35 to any other value

...