Jump to content

Date in copyright php


oggyswain

Recommended Posts

Hi I have not used php at all, but I saw a script that would save me a bit of time on various website that I handle. But I can't get it to work. Can you help me out.

 

This is the code on my site

 

<td width="675" height="44" align="center" class="footer c5" style="background-image:url(images/bot.gif); vertical-align:middle"><strong>urbanmail.ca</strong> © <?php

date.php

?> | <a href="privacy.html">Privacy Policy</a> | <a href="sitemap.html">Sitemap</a> | <a href="contact_us.html">Contact Us</a> |<a href="mailto:info@urbanmail.ca"> info@urbanmail.ca</a><br />

 

And this is the date.php script I have in my directory

 

© Copyright <?php

$then = 2007;

$now = date('Y');

if ($then == $now)

echo $now;

else

echo "$then - $now"; ?>

 

What I am trying to have it do is change the year automatically every year.

 

I have also added this to the .htaccess file

 

AddType application/x-httpd-php .html

 

Where have I gone wrong.

Edited by oggyswain
Link to comment
Share on other sites

All you need is this: (you don't need any script)

<?php echo date("Y") ?>

 

but the page must be .php, or you need to set your .htaccess to read your html pages as php.

 

 

Is there anything else I need to put in the htacess file. besides this

 

AddType application/x-httpd-php .html

 

Because I can't get it to work.

 

Thanks

Link to comment
Share on other sites

Is there anything else I need to put in the htacess file. besides this

 

AddType application/x-httpd-php .html

 

Because I can't get it to work.

 

Thanks

 

I am assuming you're uploading files via ftp - not working locally. No idea how you'd do this locally.

 

As to remote - you may have to check with your host, sometimes, they settings they require to make this work are not the 'standard' ones.

Link to comment
Share on other sites

If you can't figure this out, you can do the same thing with Javascript:

 

<script type="text/javascript">
currentTime = new Date()
document.write(currentTime.getFullYear());
</script>

 

You've checked that the server supports PHP, correct? And you are running a Linux based server? (.htaccess files won't work on Windows servers)

Link to comment
Share on other sites

If you can't figure this out, you can do the same thing with Javascript:

 

<script type="text/javascript">
currentTime = new Date()
document.write(currentTime.getFullYear());
</script>

 

You've checked that the server supports PHP, correct? And you are running a Linux based server? (.htaccess files won't work on Windows servers)

 

My service provider said It should work but it does not. There not much help.

Link to comment
Share on other sites

I'm really not sure how much more I can help you, short of you PMing me FTP information and I taking a look.

 

Have you tried using the Javascript method above, rather than using PHP? I'm not sure whether your statement "my service provider said it should work but it does not" was referring to the JS or PHP.

 

You are brilliant.

 

It worked as javascript.

 

Thanks

Link to comment
Share on other sites

This raises a question I had some time ago. Why put a date after a copyright notice? I found that some of my old pages had a fixed date which was several years old, so I wondered whether to put a PHP code for the current year, so that even though the page was coded a few years ago the date would be current, or just to leave out the date. Copyright is for ever, isn't it?

 

My websites now have a mixture of current date and no date. A question for those legal people among us.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...