Hey There,
I'm trying to get todays date to show up in a fixed position on my site using PHP but I can't seem to get it working quite right.
I have the following CSS to keep the text in where I want it to be which I think is ok:
div.date { position : absolute; top: 85px; left : 0; }
Then I have the following PHP code for the date which is in a file by itslef called date.php:
<?php $date_array = getdate(); // no argument passed so today's date will be used foreach ( $date_array as $key => $val ) ?> <? print "Today's date: "; print $date_array['mday']."/".$date_array['mon']."/".$date_array['year']; ?>
And then I have the following in my htm file to call up the PHP file:
<div class="date"><src=date.php></DIV>
However, it just won't seem to work can anyone help me out please...?
Francesco
Fixed Date Position
In what way doesn't work? What does it do?
Fixed Date Position
It's suppsed to show todays date in this format, D/M/Year but it doesn't seem to be doing anything.
Fixed Date Position
Hi Francesco
I thought you had to have your html file as a php file (ie ending in php).
My files have this in for the date:
<div class="datetoday"><?php print(Date("D, j F Y"));?></div>
No need for arrays or fancy work, this particular date format gives something like
Monday, 14 June 2004
But you can change the parameters to display it how you like.
Trevor
Fixed Date Position
Yep, I second that... here's my date code
<?php print date("H:ia D, d F Y."); ?>
Fixed Date Position
That would all probably work if I wanted to change my html files to php files but I don't want to do that. In a random background topic that I started a week ago Trevor helped me find a way to call on a PHP file from the html file and that's what I'd like to do with this date script PHP as well. Unfortunately it's not called upon quite the same way because we're not dealing with images anymore we're dealing with text. I just think I messed up calling it from within the html file...
Anybody have any ideas?
Thanks,
Francesco
Fixed Date Position
Hi Francesco
What co2 and I are saying is that you can't do it the way you want. You must call php from within a php file.
However, if you have admin control over the apache installation on your server, all is not lost (you might even persuade your host admin to help you anyway).
In the apache httpd.conf file is a line like this:
AddType application/x-httpd-php .php .php3 .php4 .phtml
This determines which files php will parse.
You can add .html .htm to the end and then they will be treated as php files.
There is also a way to do this in your .htaccess file, but this requires access to the httpd.conf file again to allow .htaccess to do this.
There is no other way of doing this. The gd library is a special library that can be called as a source file. Normal php cannot be called this way.
Trevor
Fixed Date Position
Alright cool thanks for clearing that up Trevor.
And thanks to you other guy's for the code it worked great.
If you guys wanna check out the web site I've been working on click on the link below.
Trevor you'll also notice that I'm playing around with an idea for a forum. Check it out if you want, not even sure if it's working properly at this point.
Thanks again,
Francesco