Wednesday, 23 May 2012
 Home arrow Articles arrow php arrow PHP: Print the current year for copyright notices
   
Main Menu
Home
News
Blog
Links
Search
FAQs
Spider
Articles
@intrenet
Free Softwares
Break for fun
Friends VIdeos
Techno videos
Contact Us
Disclaimer
Guest Book
Speed test
V.E.C. Calculator
IPv4 Subnet Calc
IPv6 Subnet Calc
Byte Converter
Converter
GMT/UTC Time
Bandwidth Calc
Allinone Calc
IANA Port Numbers
Country Call Codes
Pk Postal Codes
Surf Anonumously
Visitors Counter
mod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_counter
mod_vvisit_counterToday204
mod_vvisit_counterYesterday260
mod_vvisit_counterThis week464
mod_vvisit_counterThis month5013
mod_vvisit_counterAll125689
 
 
 
 


PHP: Print the current year for copyright notices PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Amanatullah khalil   
Sunday, 24 May 2009

PHP: Print the current year for copyright notices

 

Hardcoding the year in a copyright notice is an easy way to get a blog or other website started, just placing the starting and ending years next to the copyright symbol. We have the very best of intentions to change this number right after the big ball drops in Times Square each year. We’re also human and, all too often, I see websites with copyright notices that are years behind. If your website is PHP-powered, this quick bit of code will put the current year in your copyright notice and off of your mind.


To change your copyright notice, or anything else you’d like that should display the current year, you must first find the script in which the copyright display is generated. If you are using a WordPress blog, for example, this is likely in your footer.php file in the directory of the theme you are using. If you aren’t sure which file holds this, you could try searching for the text © in all of the scripts that make up your website. This is the code that generates the copyright logo and should lead you directly to the file(s) involved.

Once you’ve found this, there are two possibilities for including the year information depending on how the script is setup. It is possible that the script is sending the line including the copyright information from an ‘echo’ command in PHP, something like:

echo '© 1812–2006 Olde Time Blogs';

In this case you need to modify this PHP echo command so that it calls the PHP date command. Note that the command could also work with double quotes instead of single quotes, just be sure to keep using the same kind.

echo '© 1812–'.echo date('Y').' Olde Time Blogs';

In PHP, the period symbol is used to stitch together strings, so the command above makes one string out of three.

The other possibility is that the PHP script is formatted as HTML content with separate PHP instructions enclosed by opening/closing PHP tags. This is more proper and common in applications like WordPress. In this case, inserting a dynamic, ever-correct year is a matter of changing:

 

© 1812–2006 Olde Time Blogs

to

 

© 1812– Olde Time Blogs

courtesy http://www.tech-recipes.com/rx/2815/php_print_the_current_year_for_copyright_notices/

 
< Prev   Next >
 
 
 
csatpk Newsflash
Statistics
OS: Linux h
PHP: 5.2.17
MySQL: 5.1.63-community-log
Time: 03:56
Caching: Disabled
GZIP: Disabled
Members: 3
News: 368
Web Links: 5
Visitors: 266042
Popular