How To Display Current Year in PHP
By Angsuman Chakraborty, Gaea News NetworkSaturday, March 1, 2008
The most common use of this is to display the current year in the copyright message dynamically. Anyone who really knows PHP should be able to do it easily. However not everyone who has to use PHP knows PHP, like, for example, people using snippets in ModX or modifying templates in WordPress. Here is the code snippet for them:
<php echo date('Y') ?>
Discussion
Moshaver Melk |
March 2, 2008: 1:14 pm
You are right that the ending semi-colon is not required but the “?” is required to set off the PHP tag it won’t be parsed and will not appear as the browser will parse it as if it were an unknown HTML element. |
March 1, 2008: 12:28 pm
Um er… Your comment filter killed my code so here it is: <?php date(’Y'); ?> |
March 1, 2008: 12:25 pm
You might have better luck with the following since your PHP tag is incorrect: |
YOUR VIEW POINT
webb