PHP Date Tips & Tricks
For those of you using PHP to develop your web pages, I'm sure that you have used the date function at some point. There are so many cases that I have used this to show a date on a page, like using date("Y") in the copyright section of the footer to always reflect the current year. Here are a few tips & tricks to help you save some time.
Formatting
Predefined Constants
This is a trick that I really wish I had known about earlier. PHP 5.1.1 and forward offers date formatting constants. So when I was looking for examples on how to get the date in the correct format when creating my RSS feed, I could have simply used the DATE_RSS constant.
Example
Use:
<? echo date(DATE_RSS); ?> Output:Thu, 24 Nov 2008 12:29:09 -0500
Instead of:
<? echo date('D, d M Y G:i:s O'); ?>Output:Thu, 24 Nov 2008 12:29:09 -0500
There are eleven total predefined constants available including DATE_RSS, DATE_ATOM, DATE_COOKIE, and DATE_W3C.
User Defined Constants
Building on this same idea of constants, you could easily create your own date format constants to use. All you would need to do is define a constant with the string value of the date format and then call it within the date function. I have included a simple example below.
Example
<? define(DATE_SCOTT,'m/d/Y'); ?> <? echo date(DATE_SCOTT); ?>Output: 11/24/2008
Relative Dates
This trick is one I use when I need to get a date like tomorrow or the day after tomorrow or yesterday. The function strtotime allows you to easily calculate dates like tomorrow and yesterday. You can turn any GNU formatted date string into a PHP date. I have included a couplt of examples below that are based on a publish date of 11-24-2008.
Example
<? echo date('m-d-Y',strtotime('yesterday'));?> Output:11-23-2008<? echo date('m-d-Y',strtotime('+4 days'));?> Output:11-28-2008
Calculate Age
This trick is a fairly simple and straight forward one. All it does is find an age in years. Simply pass the year(s) you want to compare and it will return the age in year. This could easily be made into a function like getAge($yr1,$yr2);
<? echo floor(abs(strtotime('Y') - strtotime('1985'))/31536000 /*1 year in seconds*/);?> Output:23
Learn Everything About a Website From Quarkbase

Quarkbase is a website offering a mashup of information pertaining to websites. Information is gathered showing you information about a website's traffic, company, social popularity, technical specs, and more. The information is gathered from a number of sources including Zoominfo,
CrunchBase,
Bloglines,
Dmoz and Dealipedia. There is a bookmarklet available to allow you to easily get information about websites while you browse by auto loading the website you are viewing into the quarkbase website and opening the available information in a new tab (tested in Firefox).
| Progress Bar | |
| Although this feature isn't much more than eye-candy, there is a nice progress bar that indicates how much information has been compiled and how much is left. | |
| Summary | |
![]() |
The summary section displays a screenshot of the website entered as well as a general summary of information regarding pertinent information from the categories detailed below. |
| Introduction | |
![]() |
The introduction section gives a picture of the website logo and general information about the website. You can read a description of the website, see tags about the website, get links to the official about and contact pages, and see basic domain registration information. You can also see a list of websites that contain similar information and content. |
| Social Popularity | |
![]() |
The social popularity section provides information from social websites including Digg, Delicious, Reddit, Technorati, and StumbleUpon. There are counts for how many times the website entered shows up on each of these social websites. You can see some specifics like how many diggs it has received on digg, how many comments it has received on StumbleUpon, etc. The final subsection includes information about any feeds available. |
| Traffic | |
![]() |
The traffic section details what is available from Alexa. There isn't a mashup of information provided here, but it still includes useful and important information from Alexa. |
| People | |
| The people sections lists the people associated, both directly and inderectly, with the website entered. | |
| Spotlight | |
![]() |
The spotlight section shows blog entries and other websites that reference the website entered. Some sources include twitter, Google news, Technorati, and many others depending on who is linking to the website. |
| Company | |
![]() |
The company section provides information regarding who the company is, where it is located, the number of employees, when it was founded, any merger/acquisition information, and job openings available. |
| Technical | |
![]() |
The technical section lists information about who hosts the website, where the hosting is located, and what type of platform the website is using (ex: wordpress blog) |
The 5 Most Popular Posts of the Month – September 2008
The 5 most popular Posts of the month in September were:
- Learn HTML & CSS at the HTML Playground
"The HTML Playground offers XHTML and CSS references by example. The site is still in beta at version 0.4, but offers an easy to use interface that makes digesting all the information displayed simple. It is a fast loading application and I have just found it to be overall a great tool for learning the basics of HTML and CSS." - Collection of ActionScript Cheat Sheets
"ActionScriptCheatSheet.com offers a number of ActionScript related cheat sheets, including one for both version 2.0 and version 3.0 of ActionScript. There are cheat sheets listing the available packages, details about specific packages, and overviews." - How To Get Your FeedBurner Circulation With One Simple Function
"If you have visited a few blogs then I am sure you have seen the FeedBurner stats graphic. The count is very useful, but the graphic itself isn't very appealing, even with the ability to customize it. Thankfully the FeedBurner API was released, which allows you to retrieve your stats without the graphic." - 15 Places to Find Your Next CSS Layout
"Creating a theme is a multistep process. You have to pick the color scheme, decide how many graphics to include and what purpose they will serve, as well as decide on a layout. Sometimes it isn't easy to decide on a layout and it would be nice to have some examples and ideas to look at. That is what I'm focusing for this post." - Great Looking Collection of Credit Card Icons
"Do you accept credit cards through your website? It could be through any number of other third party processing companies like PayPal or Authorize.Net. If so there are some great looking credit card icons available for free. Fineicons.com offers a collection of 23 different credit card icons for download. Be sure to check them out and download for free if you like them."
What was your favorite post this month? Let us know in the comments.
How To Get Your FeedBurner Circulation With One Simple Function
If you have visited a few blogs then I am sure you have seen the FeedBurner stats graphic. The count is very useful, but the graphic itself isn't very appealing, even with the ability to customize it. Thankfully the FeedBurner API was released, which allows you to retrieve your stats without the graphic. I have taken that API and created a simple function, with the help of simple XML, to grab your circulation count and display it as text on your site without the graphic.
To start off, you will need to download the simple XML class and put it in the same folder as the file that will contain this function (or change the include path to reflect the directory of your choice). Once you have done that, you are pretty much done. All you need to do is copy the function below and call the function with your feed URI and it will return the circulation number.
You can see the function and sample usage below.
Function
function FeedBurnerCirc($feed) { include 'simplexml.class.php'; $api = 'http://api.feedburner.com/awareness/1.0/GetFeedData?uri='.$feed; $sxml = new simplexml; $sxml->ignore_level = 1; $data = $sxml->xml_load_file($api,"array"); return $data["entry"]["@attributes"]["circulation"]; }
Usage
echo FeedBurnerCirc('http://feeds.feedburner.com/webmastersbydesign');
You could also easily customize the function to include more data and return an array of results. The API returns data other that the circulation, such as your reach and views. I only wanted the circulation so I didn't return an array of results, but it wouldn't be tough to do.
Great Looking Collection of Credit Card Icons
Friday, September 5, 2008 | Images/Graphics, Webmaster 0 Comments
![]()
Do you accept credit cards through your website? It could be through any number of other third party processing companies like PayPal or Authorize.Net. If so there are some great looking credit card icons available for free. Fineicons.com offers a collection of 23 different credit card icons for download. Be sure to check them out and download for free if you like them.
The collection includes icons from: Visa, Visa Electron, Mastercard, Cirrus, American Express, Paypal, Moneybookers, Solo, Swich, JCB, Delta, Discover, Dinersclub, Easy Cash, E-gold, Western Union, Cash U, Laser, World Pay, Alipay, ICBC China, and Neteller.
I have only detailed the credit card collection, but Fineicons.com has other collections worth taking a look at. They also offer nice collections for Web Symbols, RSS Feed, Computer Micro Stock, File Types, and Flags of the World.
Other Credit Card Icons
FeedBurner Access Has Been Intermittent
Tuesday, August 19, 2008 | Announcement 0 Comments
FeedBurner has become very intermittent for me. I am unable to load a page and then the next refresh brings it up and then the next page I try to load fails to load. I have received multiple errors including "The connection was reset" and "Http/1.1 Service Unavailable". Here are the screenshots.


Is anyone else experiencing this?
The Best Firefox Developer Extensions Around
Firefox offers a lot of advantages over other browsers, namely Internet Explorer. One of the greatest advantages it offers, is the ability to install add-ons. There are plenty of great plugins available for developers to use to help them make better websites and make them easier to navigate. There are extensions that cover SQL, regular expressions, debugging, security issues, FTP, and more. Here is a list of 20 great Firefox extensions for developers.
- Firebug - This extension provides debugging capabilities while viewing a web page. There is live debugging on CSS, HTML, and JavaScript. It is recommended to turn off this extension while not debugging, due to a speed lag in browsing.
- FireFTP - This extension is a full featured FTP client that integrates into Firefox. It is free and includes features like drag & drop, encryption, search, directory comparisons, and directory syncing, just to name a few.
- FireShot - This extension takes screenshots of web pages. It allows you to save the image, copy it to the clipboard, and edit the screenshot. You can also choose to capture only the visible area or the whole page. This is a very useful extension for bloggers who often review web pages.
- Screengrab - This extension is another extension that allows you to take screenshots of web pages. The features include saving the image or copying to the clipboard. It also supports capturing the visible area, the entire page, a selection, or a frame.
- Greasemonkey - This is one of the coolest extensions available. It allows you to customize how web pages behave using JavaScript. There are hundreds, if not thousands, of scripts available to download, and you can create your own. This is an easy way to improve on web pages that you didn't create, as well as the ones that you did.
- Web Developer - This extension adds a toolbar that has a large selection of webmaster tools and resources. It includes the ability to view the source and the CSS easily by loading them into a new tab within the current window. It allows for one-click validation of HTML, CSS, Feeds, and more. Other features include information and manipulation of images, forms, and cookies.
- YSlow - YSlow is an extension developed by Yahoo! to help understand why a web page is slow. There are report cards generated that detail why the web page is performing poorly based on Yahoo's rules for a high performing website.
- HTML Validator - This extension integrates HTML validation directly into Firefox. The validation is based on Tidy and gives detailed output of the errors that are found. Icons are visible in the status bar that give general counts for errors and warnings.
- JavaScript Debugger - This extension provides feedback for JavaScript errors. This is very useful when needing to determine what has gone wrong. It provides a lot of detailed information to help you troubleshoot and fix the problem.
- Dummy Lipsum - This extension provides on-the-fly creation of Lorem Ipsum dummy text to use as a placeholder. Lorem Ipsum text has become the universal default text used as a placeholder in web pages, and this extension provides a fast and easy solution. You need a minimum of 5 words, but you can create many paragraphs worth of text if needed. This is a very useful time saver.
- SQL Inject Me - This extension is a security tool for checking the vulnerability of your forms. It submits your forms with typical SQL injection values and the shows the database errors that occur.
- XSS Me - This extension is very similar to the SQL Inject Me extension. It is a security tool that tests the vulnerability or your site to XSS, or cross-site scripting, attacks.
- ColorZilla - This extension provides an eyedropper and color picker for web pages. You can easily determine what color is being displayed on the page and then create custom color palettes from it.
- Regular Expressions Tester - This extension provides testing capabilities to your regular expressions. You can plug the expressions in here and determine if they are correct and will do what you wanted them to do. It includes a save feature that allows you to keep previously tested regular expressions readily available.
- XML Developer Toolbar - This extension is very similar to the Web Developer extension. It tracks a large range of items pertaining to XML. It allows for validation, generation, and manipulation of XML schemas, DTD's, and XSL's.
- Load Time Analyzer - This extension was developed by Google and is used to track and report on how long it takes a web page to load. The output is very easy to read in graph form. You can customize what events you would like to measure.
- Server Switcher - This extension is very handy for switching between your development server and your live hosting server. It allows you to switch between each in one click, or keyboard shortcut, and is completely customizable to your servers.
- Window Resizer - This extension allows you to switch between different resolutions and screen sizes for testing your layout. This is great for designing themes, because of the obvious need to accommodate as many resolutions as possible.
- SQLite Manager - This extension is used to manage SQLite databases on your computer. You can browse, search, edit, add, and delete using this tool. You can also run SQL queries against the database. This is a very nice tool if you use SQLite.
- MeasureIt - This is a very simple, yet very useful extension. It is basically a ruler that allows you to find out how much space something is taking up on the page. This is good for developing themes and working on the layout of your web page. It can save you a lot of time, since you won't need to guess and try different pixel dimensions.
What other extensions do you use to help you when developing websites? Let us know in the comments.
10 Great Facebook Developer Resources
Facebook just recently celebrated their one year anniversary for the release of their developer platform. The API was released on May 28, 2007 and has exploded with user applications since then. The application directory has tens of thousands of applications, some with over 1.5 million daily users. For those of you, like me, who may not have jumped on the bandwagon right away, here are some great tutorials and information to get you started now.
- Facebook Developer Documentation - This is the main Facebook Developer website. It has all kinds of information from a wiki, to tutorials, to getting started guides.
- Facebook PHP Tutorial - This is a great tutorial for beginners. It goes through the very basics of what is needed to begin developing with the Facebook APIs and PHP. It Includes a basic application example.
- Developing with the Facebook Platform and PHP - This is another great tutorial for PHP developers, this time from Sitepoint. It covers the basics and gets a little more in-depth, covering topics like the News Feed and the User Profile Box.
- How to Develop a Hit Facebook App: 29 Essential Tools and Tutorials - This is not a tutorial, but a site that links to 29 useful websites that provide more information to help you in your journey to create the next best Facebook App.
- An Introduction to FBML - This link provides a nice overview to FBML (Facebook Markup Language). It is fairly basic, but an easy read. Definitely recommended when in need of a quick understanding.
- Facebook Developer Tutorials - A good listing of many tutorials covering many different topics. There is a lot of good information here. It is definitely worth checking out.
- How to use the Facebook API - This is a very basic overview of the API. It offers some good information, but is very short and to the point.
- Getting Started with the Facebook Platform API (Screencast) - There are 3 screencasts here that cover the basics of setting up an application through Facebook and writing the code once the application has been set up through the Facebook developer application.
- How To Set Up A Facebook Feed Reader Application For Your Blog - HowtoForge gives a nicely written tutorial on how to create an RSS feed reader application. This is a great tutorial and a great idea. This is a good way to spread the word about your blog in a fairly easily.
- Facebook Development Kit - Here is a development kit released by Microsoft, that includes control and samples for both Visual Basic and Visual C#. The site includes some nice walkthrough videos as well.
What other resources have you used to learn your way through the Facebook API's? Let us know in the comments.
Real Time Website Stats From W3Counter.com
I ran across a new website, W3Counter, that offers free tracking of your website stats. It has the look and feel of Google Analytics. I was registered, set up, and ready to add the tracking code in only a few minutes. This site has some definite potential.
The Good:
- Real Time Stats - The website offers you free real time tracking of your website. You can have up-to-the-second information about what is happening on your website.
- Attractive Interface - The website offers a nice and easy to follow? interface to allow you to easily find and view your data. It is easily navigated and easy to follow the flow of drill-down information.
- Attractive Information - The website offers nicely designed graphs, charts, and reports to help you turn data into useful information. It is easy to know what your are looking at and understand what is being presented. There is not much of a learning curve.
- Online Now - The website offers a nice feature that shows you who is currently visiting your website.
- Live Map - The website offers a live map to show where the people that are viewing your site are located at the moment they are viewing your site (Paid version). The visitor locations are mapped on a Google Map.
- WordPress Plugin - The website offers a free plugin for WordPress integration. The plugin adds an overview to the dashboard and lets you get an idea of where you stand at any given time. This works very well and is easy to install and set up.
The Bad:
- No Free Lunch - The saying "there is no such thing as a free lunch" applies here. Although the website offers free tracking, there is a cap of 5,000 page views per day before needing to upgrade to a pro account for $9.95/month. 5,000 page views per day is a small number. This would be alright for websites starting out, but wouldn't last very long once a reputation is established and quality content is driving traffic.
- Visual Presence - The free version requires a visual counter or link on your page and will show up wherever you place the tracking code. Again this can be removed for $9.95/month.
- Website Limit - The free version only allows you to track 1 website per account. Again, this is probably alright for some, but not feasible for many webmasters that maintain multiple websites.
- No Exports - There is no way to export the data as a PDF, CSV, XML, or any file for that matter. The paid version offers an RSS feed, as well as email updates regarding your stats.
Internet Explorer 8 Beta Overview
Microsoft has released Internet Explorer 8 Beta. This release is meant mostly for developers and designers, so that they can test the new browser. "Internet Explorer 8 will take the web experience beyond the page. Internet Explorer 8 introduces a new way to seamlessly experience the best of the web whether you are a web developer writing to standards or a user discovering a new online service" (Microsoft.com). Here are some new features and improvements worth noting.
- WebSlices - WebSlices are similar to live bookmarks in FireFox. They provide a way to get updated content without visiting the website a bunch of times a day. Unlike the RSS text version of FireFox's live bookmarks, IE8's WebSlices allow for parts of a web page to be updated (It looks like a website, not like an RSS feed). There are WebSlices available from eBay and StumbleUpon already.
- Activities - Activities enable you to access other services from within a webpage, such as submitting to Digg, looking up information, or mapping an address. The Activities icon? is loaded in a context menu similar to a right click menu in windows.
- Layout Engine - IE8 has a new layout engine with many improvements for how a page is loaded and rendered. As always, this upgrade can cause problems with websites that were developed for IE7. Microsoft took this into account, however, and allows for a webpage to tell IE8 to render the page as IE7.
- CSS 2.1 Compliant - IE8 will eventually be fully CSS 2.1 compliant. They are continuing to work with developers and designers to work out bugs in the Beta, but will have it fixed in the final release.
- Improvements - IE8 has had an overhaul and now has improvements in HTML rendering, namespace support, and platform performance. These improvements will help IE8 run better as a whole.
- Developer Tools - IE8 now has developer tools built into the application. They provide most of the functionality of the web developer FireFox extension.
- Improved Security - IE8 has also been given more security features to protect you as you browse. There are 3 main exploits that are protected against in IE8: they are social engineering, web server, and browser-based exploits.
You can download you copy of IE8 here. Please comment below and let us know what you think of the IE8 Beta.






