> -----Original Message-----
> From: Jack [mailto:[email protected]]
> Sent: Wednesday, December 07, 2011 1:49 PM
> To: PHP
> Subject: [PHP] Problem with date
>
> Hello All,
>
>
>
> I have a problem where Dates are coming out as 12.31.1969 19:00:00
> which of
> course we didn't have PC's in 1969
>
> I'm not able to see where the date is getting screwed up, any ideas??
>
>
>
> //
> #######################################################################
> #####
> #
>
> function ShowFeed_RSS($XmlRoot) {
>
> $title = GetFirstChildContentByPath($XmlRoot, "channel/title");
>
> $link = GetFirstChildContentByPath($XmlRoot, "channel/link");
>
> $desc = GetFirstChildContentByPath($XmlRoot, "channel/description");
>
> # Next 2 lines display the title of the feed, and feed description
>
>
> # echo "<font face=arial color=blue size =2><b><a
> href=\"$link\">$title</a></b>\n";
>
> # echo "$desc";
>
> $nodelist = GetChildrenByPathAndName($XmlRoot, "channel", "item");
>
> if (!$nodelist) return 0;
>
> foreach ($nodelist as $nl) {
>
> $title = GetFirstChildContentByName($nl, "title");
>
> $link = GetFirstChildContentByName($nl, "link");
>
> $desc = GetFirstChildContentByName($nl, "description");
>
> $creator = GetFirstChildContentByName($nl, "author");
>
>
>
> # if (!$creator) $creator = GetFirstChildContentByName($nl,
> "dc:creator");
>
>
>
> # echo "JACK" . $nl . "<br>";
>
> # $pubdate = GetFirstChildContentByName($nl, "pubDate");
>
> if (!isset($pubdate)) $pubdate = GetFirstChildContentByName($nl,
> "dc:date");
>
> # if (!$pubdate) $pubdate = GetFirstChildContentByName($nl,
> "dc:date");
>
> if (isset($pubdate)) $pubdate = strtotime($pubdate);
>
> if (isset($pubdate)) $pubdate = strftime("%m.%d.%Y %H:%M:%S",
> $pubdate);
>
> $out = $creator;
>
>
>
> if ( ($creator != "") && ($pubdate != "") ) $out .= " @ ";
>
>
> $out .= $pubdate;
>
> echo "<a class=\"rss-link\" href=\"$link\"><b>$title</b></a>";
>
> echo "<font size=1 color=\"black\"> $out<br>";
>
> echo "<font size=2>$desc<br><br>";
>
> # echo "<font size=1 class=rss-link>This is not green</font>";
>
>
>
> }
>
> # this line is after each rss feed group
>
> # echo "<hr>\n";
>
>
>
> }
>
>
>
>
>
>
>
> Thanks!
>
> Jack
>
>
Suggestion only.
if (isset($pubdate)) $pubdate = strtotime($pubdate);
if (isset($pubdate)) $pubdate = strftime("%m.%d.%Y %H:%M:%S", $pubdate);
could be
if (isset($pubdate)) $pubdate = mktime("m d Y
H:i:s",strtotime($pubdate));
Reducing the code
I also changed this to MKtime from strftime because The %e modifier is not
supported in the Windows implementation of this function. To achieve this
value, the %#d modifier can be used instead. The example below illustrates
how to write a cross platform compatible function.
Please read on the MKTIME function
http://php.net/manual/en/function.mktime.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php