How would I go about displaying the current time and date in my site's header?

I haven't found any information on the topic.

Thank you.

Comments

Bill Shaw’s picture

Is there a way to have the current date and time posted on a page?

I am not too concerned which area of the page it needed to be, it would just be nice if the current date and time were included when a page on the site was downloaded.

Drupalace-1’s picture

Any objection to doing it via PHP? A little Googling turns up any number of how-tos, like this simple one:
http://www.totallyphp.co.uk/code/display_date_and_time_with_php.htm

I just gave that one a shot on my site, and wrote up the process a bit, at http://www.drupalace.com/questions/how_display_date_and_time . No fancy options, just date and time, but is it on the right track for you?

--------
A site by, of, and for the Drupal newbie: http://www.drupalace.com

Bill Shaw’s picture

Works beautifully.

I shortened up the code to only display the date, until I fugre how to account for time zones. But until then, this gets me there ;)

Thanks!

Bill Shaw’s picture

Works beautifully.

Used the new block method from drupalace.com

I shortened up the code to only display the date, until I fugre how to account for time zones. But until then, this gets me there ;)

Thanks!

vthirteen’s picture

what's the best way to get current date translated?

(i posted the same question here before finding this thread: http://drupal.org/node/206511 )

kryptum’s picture

<?php if ($submitted) { ?>
  <p class="node-meta">
    <span class="node-meta-day"><?php  echo date("j", $node->created); ?></span>
    <span class="node-meta-month"><?php echo date("M", $node->created); ?></span>
    <span class="node-meta-year"><?php echo date("Y", $node->created); ?></span>
  </p>
<?php } ?>

http://php.net/manual/en/function.date.php

Or replace <p> with the <date> html5 tag

Jaypan’s picture

Actually you can use the format_date() function in Drupal, which will adjust for time zone.

Also, the thread is about showing the current time, so you would want to use REQUEST_TIME instead of $node->created.