What better way to get your visitors to act now than to give them a deadline? "Act now! This offer expires tomorrow!" In this lesson we look at Date Scripts, the Internet Marketer's best friend.
You can use a date script to generate a date automatically, without having to go into your HTML every day and change the date yourself. With a few easy tweaks you can make the script generate today's date, yesterday's date, tomorrow's date, or any number of days into the past or future.
This means that no matter when your visitor is looking at your site, the psychological effect of the date is the same. "Oh gosh, that's tomorrow!" or "Wow, this was updated today..."
Try pasting this snippet of code into your web page (make sure you're in "code" view if you're using a WYSIWYG editor):
<?php echo "Order by ".date("jS F Y", mktime(0, 0, 0, date("m"), date("d");+3, date("y")); ?>
Save this as a .php file (or in an existing PHP file). Because it's a PHP file it's very likely that you won't be able to preview the page on your computer, so you might need to upload it to your website to see it in action.
What you should see is this:
<?php echo "Order by ".date("jS F Y", mktime(0, 0, 0, date("m"), date("d")+3, date("y"))); ?>
This date is three days into the future. That's because of the +3 in that line of code above. If you wanted your date to be just one day into the future (and get a more immediate response out of your visitors) then change that little number to a 1 instead of a 3.
<?php echo "Order by ".date("jS F Y", mktime(0, 0, 0, date("m"), date("d")+1, date("y"))); ?>
To get today's date, simply drop that little number altogether.
<?php echo "Order by ".date("jS F Y", mktime(0, 0, 0, date("m"), date("d"), date("y"))); ?>
In the above snippet of code, the letters jS F Y determine how the date displays.
To change how the date displays, you just need to change or re-arrange these letters. For a full list of different date format options, there is a useful chart at http://de3.php.net/date.
For PHP to work on your page, you have to save the page as a .php document.
In this lesson we looked at how you can use a bit of PHP to dynamically and automatically update relevant dates on your webpage, either to show a page was recently updated, or to give a sense of urgency (e.g. for a purchase). We took a look at: