PDA

View Full Version : Todays Date on Webpage


polygon
11-11-02, 09:19 AM
Anyone know where I can find the CGI code to add the Date to my web page? I know there are probably services just like the "search your site", but I don't want anything else needing to be downloaded from anywhere else. I just hate sites that download things from a million other places before they display the page I'm interested in.

Thanks in advance!

alphadesk
11-11-02, 09:47 AM
Add this to where you want the date to show on your page.

<script>

var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
document.write("<small><font color='336699' face='Verdana' size='1'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>")

</script>

NMS
11-11-02, 10:11 AM
This is funny...Yesterday I had the idea of placing the date in certain areas of a particular website which I am designing.

Today I poped in the forums and found the right script without even searching...

Thanks alpha... :D

GearHead
11-11-02, 11:07 AM
Nice... Thanks for the script.. got any more?

Fraki
11-12-02, 11:46 AM
What about showing todays date on a webpage using graphics. Such as having a graphic for each number (1.gif, 2.gif, 3.gif and so on), and have the script call up the right digits for each day.

Laurey
11-12-02, 12:24 PM
Or you could just use SSI if it's an shtml page:

<!--#config timefmt="%B %d, %Y-->
<!--#echo var="DATE_LOCAL"-->

-L

NMS
11-12-02, 03:59 PM
do you have somthing in php? :)

Laurey
11-12-02, 04:16 PM
Did a search on google.. (php echo date), and a ton of things popped up.. some looked usefull.. but as I haven't delved into PHP... I've not a clue if any were valid...

One of these day's I'll have to add php to my bag of trix..

polygon
11-12-02, 04:30 PM
Thanks everyone! I had tried Matt Wright's cgi script from scriptarchive.com, but it keeps giving me a server error. I'm sure it will work, I just don't know enough about perl....

Laurey
11-12-02, 04:38 PM
Did you upload in ASCII mode? did you remember to CHMOD to 755?

What's the error? and what's the URL to the script and/or page calling the script?

-L

polygon
11-12-02, 04:46 PM
There is a comma missing from the script that yields a "unterminated string constant" error:
In the last line:

"+daym+", "+year+"</b></font></small>")

must be:

, "+daym+", "+year+"</b></font></small>")


Works great! Thanks!...

polygon
11-12-02, 04:52 PM
Laurey:

Yes I did upload in ASCII mode and CHMOD'ed it to 755. I don't have the other info. I remember it saying something about a folder not being found. I only tried it twice and then deleted it from the page.

I'm going to use the script that alphadesk posted. Thanks for helping!....

Mick
11-16-02, 08:54 PM
Here is s small code snippet I have been using a long time. It will put the day of the week, the date, and the time on your page. You can use any one of those three or just one of them.
---------------------------------------------------------------
<?php
$hourdiff = "2"; // hours different between server and local time
$timeadjust = ($hourdiff * 60 * 60);
$melbdate = date("l, F dS, Y * g:i a",time() + $timeadjust);
print ("$melbdate");
?>
----------------------------------------------------------------
You can also adjust it if your local time is different from the server.
Give it a name of your choice, make the extension .php and chmod it to 755 and all should be well.
Mick

patricko
11-17-02, 03:13 AM
http://javascript.internet.com/calendars/daily-greeting.html


Just in case

Jade Dragon
11-22-02, 10:45 AM
Simple php what will pull the date but not the time. <!--- php clock --->
<p><?
/*
** print today's date
*/
print(date(" F dS, Y"));
?>
</p>
<!--- End php clock --->