PHP Класс FeedTime, feedwordpress
We will try to be as tolerant as possible of different representations, since
RSS Is A Fucking Mess, broken dates seem to be especially pervasive, etc.
Supports anything that your version of PHP's strtotime() can handle; also has
a built-in parser for W3C DTF, in case your PHP doesn't have that.
Tries to parse a W3C DTF first; then falls back to strtotime(). If strtotime
fails due to a mystery timezone, then we will try again on local time, with
the timezone stripped out.
To parse a string representation of a date-time from a feed, instantiate and
then pull the timestamp:
$time = new FeedTime($s);
if (!$time->failed()) :
$ts = $time->timestamp();
else :
...
endif;
Показать файл
Открыть проект
Примеры использования класса
Открытые свойства
Открытые методы
Метод |
Описание |
|
FeedTime ( $time ) |
* FeedTime constructor |
|
__construct ( $time ) |
|
|
failed ( ) |
* FeedTime::timestamp() |
|
parse_w3cdtf ( ) |
FeedTime::parse_w3cdtf() parses a W3C date-time format date into a
Unix epoch timestamp. Derived from the parse_w3cdtf function included
with MagpieRSS by Kellan Elliot-McCrea , with
modifications and bugfixes by Charles Johnson
, under the terms of the GPL. |
|
set ( $time, $recurse = false ) |
|
|
timestamp ( ) |
* FeedTime::set() |
|
Описание методов
FeedTime()
публичный Метод
__construct()
публичный Метод
parse_w3cdtf()
публичный Метод
FeedTime::parse_w3cdtf() parses a W3C date-time format date into a
Unix epoch timestamp. Derived from the parse_w3cdtf function included
with MagpieRSS by Kellan Elliot-McCrea , with
modifications and bugfixes by Charles Johnson
, under the terms of the GPL.
public set ( $time, $recurse = false ) |
timestamp()
публичный Метод
Описание свойств