Webmasters Tricks
*

My Tricks
Home Using "www2" Favicon Autodate Translation Tooltips Link Cloaking Track With 1 Pixel PHP Autodate SEO & Tables Screen Capture Website Scruffies
My Tools
Newbies School of Internet Marketing CheatKit Graphics Wizard CheatKit ListBuilder CheatKit Viral ListStorm Survey Convertor The Free Trial Machine ExitBlocker Cloak & Track Toolkit Forum Marketing Kit Scroller Control Newbies Starter Kit Ultimate Package Brander Affiliate PDF Brander Turbo Content SiteBuilder Content Rewriter Pro Grab That Sale! Web Protect Pro

Webmasters Cheat Kit - A Range Of Easy To Use Website ToolsPut some of my "tricks" to work on your website. The Webmasters CheatKit range of products helps you to build professional websites without needing a load of techie skills!

Click Here To Find What's In The "CheatKit"!

Sneaky Autodate With PHP

In my "trick" about "Autodate", I showed how you can display the current date on a web page using a bit of JavaScript. This works well, but savvy web visitors might just have a look at the source code for your web page and realise that it's not really a genuine current date that is hard-coded into the web page.

But if you use "PHP", you can fool even these web-savvy visitors.

PHP is a very powerful web scripting language. Extremely complex websites have been built using this language. But it is also possible to take tiny snippets of PHP code and use them to enhance your website.

The only restriction is that any page you build which has PHP code in it must end with the ".php" file type, not ".html" or ".htm". OK, there are ways around this, but that's another story. But most web hosting accounts (including my Hosting4Marketing web space packages) support PHP.

So, how do you code the current date in PHP? It's really very simple. Here's the code:

<?php
$today = date('F j, Y');
PRINT "$today";
?>

If someone looks at the source code of your page, they won't see the code - just the current date. Here's the proof:

Today's date is January 6, 2009

.. and that's what you'll see if you look at the source code of this page.

You can do all sorts with this code snippet. You can, for example, change the parameters to show the date in a different format. In the above example, the "F" displays the current month, the "j", the day of the month and the "Y", the year (4 figure format. So here's another example of the code:

<?php
$today = date('l, j M, y');
PRINT "$today";
?>

This is a different date format: Tuesday, 6 Jan, 09

See if you can work out what the new parameters represent :-)

You can even set the date to show a set number of days in advance:

<?php
$today = date('F j, Y',strtotime("+4 days"));
PRINT "$today";
?>

That displays the date 4 days from now (just change the figure in red to what ever you like. Here's the proof:

In 4 days time, it will be January 10, 2009

There are a lot of different parameters associated with the PHP "date" function and you can get a full list of all the parameters here:

http://www.php.net/date

When you insert these code snippets into your web pages, make sure that you do this in HTML mode if you're using a WYSIWYG web page editor (such as FrontPage, Dreamweaver or NVU). What I normally do is to type the words surrounding the code in WYSIWYG mode, and then put "xxx" in as a place marker, such as

I will be raising the price on xxx so buy today

I then switch to the HTML mode and replace the "xxx" with the PHP code.

Warning: When I make a special offer to my subscribers, I do not use this technique. It's a real date that I set and I keep to it!

I hope you've found this little "trick" useful. Enjoy!

These "Webmasters Tricks" are presented without any guarantee that they will work on your website, on your computer or in your browser! As with any technology, you must test everything very carefully!

Ian Traynor is a professional webmaster and internet marketer. He owns the Webmasters CheatKit range of products, and produces the weekly "Marketing Update" newsletter. You can