W3CDTF date in PHP

To create a date time in the W3CDTF format (used in RSS feeds).W3CDTF date format is required for RSS validation. Use following PHP code.

1
2
3
4
<?php
$date=substr(date("Y-m-dTh:i:sO"),0,22).":".substr(date("O"),3);
echo $date;
?>

above code will giveĀ  output like : 2009-01-28T01:49:16-07:00