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

No related posts.

Tags: , , , , ,

1 Comment

  1. Mike Litzkow /

    In PHP 5 you can use a built-in constant string:

    $date = date(DATE_W3C);

Leave a Reply