You are here

function _parser_common_syndication_parse_date in Feeds 7

Same name and namespace in other branches
  1. 8.2 libraries/common_syndication_parser.inc \_parser_common_syndication_parse_date()
  2. 6 libraries/common_syndication_parser.inc \_parser_common_syndication_parse_date()
  3. 7.2 libraries/common_syndication_parser.inc \_parser_common_syndication_parse_date()

Parse a date comes from a feed.

Parameters

$date_string: The date string in various formats.

Return value

The timestamp of the string or the current time if can't be parsed

3 calls to _parser_common_syndication_parse_date()
_parser_common_syndication_atom10_parse in libraries/common_syndication_parser.inc
Parse atom feeds.
_parser_common_syndication_RDF10_parse in libraries/common_syndication_parser.inc
Parse RDF Site Summary (RSS) 1.0 feeds in RDF/XML format.
_parser_common_syndication_RSS20_parse in libraries/common_syndication_parser.inc
Parse RSS2.0 feeds.

File

libraries/common_syndication_parser.inc, line 490
Downloading and parsing functions for Common Syndication Parser. Pillaged from FeedAPI common syndication parser.

Code

function _parser_common_syndication_parse_date($date_str) {

  // PHP < 5.3 doesn't like the GMT- notation for parsing timezones.
  $date_str = str_replace("GMT-", "-", $date_str);
  $date_str = str_replace("GMT+", "+", $date_str);
  $parsed_date = strtotime($date_str);
  if ($parsed_date === FALSE || $parsed_date == -1) {
    $parsed_date = _parser_common_syndication_parse_w3cdtf($date_str);
  }
  return $parsed_date === FALSE ? time() : $parsed_date;
}