Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Bill Shaw on
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
try this another way...
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.
Use PHP to display date and time
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
Thanks!
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!
Thanks!
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!
translate current date/time
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 )
http://www.drupalace.com/ques
http://www.drupalace.com/questions/how_display_date_and_time
In D7 & D8 see REQUEST_TIME
https://api.drupal.org/api/drupal/includes!bootstrap.inc/constant/REQUES...
-
http://php.net/manual/en/function.date.php
Or replace
<p>
with the<date>
html5 tagActually you can use the
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.