readers
CHEXED
Create the Sitemap Date Using PHP
 

By: David Rader II on September 18, 2007 @ 3:04 PM

According to the sitemap protocol adopted by Yahoo, Google, and Microsoft, the W3C time formatting standards are acceptable for sitemaps.

I'm writing this to provide some ease of use to find a PHP method of generating the time for sitemaps.

To update it with just the YEAR-MONTH-DAY use date('Y-m-d')
Example echo date('Y-m-d');

Here's how to include the hours (in always two didget 24 hr timeformat, with 2 digit minute format as well, plus the timezone ("P" capitalization matters)

";
date('Y-m-d\TH:iP'); If your PHP is before version 5.1.3, then you may have to finegle the code to look like this: date('Y-m-d\TH:i-4:00') where "-4:00" is your local timezone (where you're publishing from... The timezone to be used is the Greenwich mean time zone (GMT).... You can find your timezone for your country and location here. It may begin with a + or a -

The backslash before the T will allow the T to stay a "T" you must have a backslash before each letter you want to show (escaped). The T on the end indicates to assign a timezone.

More W3C acceptable datetime formats.

Other tip:
Be sure to replace your ampersands (& and symbol) with &.. to do this you can use the command:
str_replace("&","amp;",$dataToHaveAmpersandsStripped);

Sorry if my English is bad, when coding my people language skills sometimes are dampened.




Comments:






Privacy |Contact
Copyright Chexed 2015.

Hosted by HostNine
This page was created in 0.0274970531464 seconds.