Does anybody know of code to display the date on my website in the format Friday, 16 October 2009 using Arial font size 2 or 3 colour CC5617 ??
| SitePoint Sponsor |
Does anybody know of code to display the date on my website in the format Friday, 16 October 2009 using Arial font size 2 or 3 colour CC5617 ??

Well, that's quite a loaded question... did you want the date dynamically entered into your website or are you adding the date to posts manually? If you are adding it manually then no problem, if you want to edit it dynamically you will either need to use JavaScript (if you want to display the current date) or a server-side script (if you want the date of the post). As for the style, what font measurement are you intending on using? they don't come in 2 or 3, it's usually a measurement unit like px, em, % or something similar (the font, size and color would need to use CSS, not HTML). And as for the whole thing itself, where are you intending on adding it? It depends where it's going and what the rest of your code is as to what html element you need to use.
Really we can't help you unless your MUCH more explicit with your question.
Hi Alex, what I want to do is to have the day date display on the webpage and to update dynamically. The only example I can think of is the bbc website. it has a clock in the top right corner and below it has the date, does that help? sorry to be so ignorant...
Yes, I want to display the current date so JavaScript is what is needed I guess. For the font measurement I am unsure of the px but it is roughly size 10 font if that makes sense? I would just place it somewhere in the body.


Hi klorigan,
You can easily use PHP to place the date on every page, like this:
That will echo the date for your own server (i.e. if the server is in the US, it will show local US date--unless you've specified otherwise). There are ways to make the time vary depending on the site visitor's location. For example, here is how to set a time for both the server location and a visitor say in Melbourne, Australia (where I am):PHP Code:<?php
$timestamp = time();
echo date("l, F jS Y", $timestamp);
?>
As for the font size issue, the font size = 3 is old presentational HTML markup, like this:PHP Code:<?php
$timestamp = time();
echo date("l, F jS Y", $timestamp) . '<br />'; // server time
date_default_timezone_set('Australia/Melbourne');
echo date("l, F jS Y", $timestamp) . '<br />'; // Melbourne time
?>
You should avoid this like the plague. Better to do this in your HTML:Code:<p><font size="3">Friday, 16 October 2009</font></p>
and then this in your CSS file:Code:<p class="date"><?php $timestamp = time(); echo date("l, F jS Y", $timestamp); ?></p>
Hope that's all clear!Code:.date { font-size: 10px; /* adjust to suit */ color: #CC5617; font-family: arial, verdana, helvetica, sans-serif; }
Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form
Try your hand at the new JavaScript Challenge!
If you don't like getting your feet stuck in a bog, avoid Twitter BootsTrap.

Sorry about the lateness of my reply, the below website has plenty of examples of JavaScript clocks which will update as you want it too (or at least what you have been hinting at). As for the font size all font's are declared in a specific measurement (like px), If you mean font size 10 as in what a word processor would use (they tend to be undefined) it would be in pt (points) rather than anything else, though i would highly advise you don't use PT as it's not intended for anything other than print media. I would start by using font-size: 14px; in your CSS and then adjust it to meet your needs.
http://www.dynamicdrive.com/dynamicindex6/
Thanks Alex, I appreciate this very much. However, when I said newbie what I meant was newborn foal trying to gallop before I can even stand up...!
I can place code to the body or the head and don't understand when people say put in your css. I do know what css is just haven't used it.
Again, sorry for being so useless....!
Thanks Ralph, if you see my reply to Alex below you will understand that I need step by step.....arrgghh.
I understand the code as you present it but I don't have css I can place code in body or head???


OK klorigan, to be clearer, just do these three things (if you want to utilize my PHP example):
1. Make sure that your page has a .php extension. (For example, instead of index.html, call it index.php.)
2. Place this in your HTML (that is, in the <body> section) wherever you want the time to appear:
3. Place this code in the <head> section of any page on which the time is to appear:Code:<p class="date"><?php $timestamp = time(); echo date("l, F jS Y", $timestamp); ?></p>
If you want the time to appear on multiple pages, that last step is quite inefficient, as you would have to revisit each page if you ever wanted to change your styles.Code:<style type="text/css" media="all"> .date { font-size: 10px; /* adjust to suit */ color: #CC5617; font-family: arial, verdana, helvetica, sans-serif; } </style>
A better approach is to create an external CSS file. For example, create a new page called time.css and, for argument's sake, place it in your root folder (where your home page is).
In that file stick this code:
Then in the <head> section of each page, place this code:Code:.date { font-size: 10px; /* adjust to suit */ color: #CC5617; font-family: arial, verdana, helvetica, sans-serif; }
This is better because, if you later want to change your styles, you can do so in one loaction, and all pages will be updated at once.Code:<link type="text/css" media="all" rel="stylesheet" href="/time.css">
I hope these instructions are simple enough to follow!![]()
Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form
Try your hand at the new JavaScript Challenge!
If you don't like getting your feet stuck in a bog, avoid Twitter BootsTrap.
Thank you for this instructions this will help me a lot!![]()
Easy Website Builder | Building Website Fast and Easy
Hevla Coffee Co. | Low Acid Coffee and Accessories.

Just a note: Using that code means you will get a time stamp upon the pages loading, however this isn't dynamic and does not alter by the second (as I thought you wanted) for that your would need to employ the use of JavaScript following the instructions for the examples, or perhaps Ralph's solution was what you wanted![]()
Bookmarks