Re: [PHP] Problem with date
$pubdate is probably null or something. Regards, –Josh Joshua Kehn | @joshkehn http://joshuakehn.com On Dec 7, 2011, at 1:48 PM, Jack wrote: 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 =2ba 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\$outbr; echo font size=2$descbrbr; # echo font size=1 class=rss-linkThis is not green/font; } # this line is after each rss feed group # echo hr\n; } Thanks! Jack
Re: [PHP] Problem with date
On 12/7/2011 10:48 AM, Jack wrote: 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 =2ba 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\$outbr; echo font size=2$descbrbr; # echo font size=1 class=rss-linkThis is not green/font; } # this line is after each rss feed group # echo hr\n; } Thanks! Jack Can you supply an example of the data you are feeding this. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ C - (541) 408-5189 O - (541) 323-9113 H - (541) 323-4219 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with date
How about a little debugging here (and possibly elsewhere): if (isset($pubdate) ($pubdate 0)) { $pubdate=strtotime($pubdate); } else { die(Barf. Can't run a string to time conversion on 0 or -1.); } Thanks Kevin, This bombs and gives me the BARF! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with date
How about a little debugging here (and possibly elsewhere): if (isset($pubdate) ($pubdate 0)) { $pubdate=strtotime($pubdate); } else { die(Barf. Can't run a string to time conversion on 0 or -1.); } Thanks Kevin, This bombs and gives me the BARF! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with date
To: PHP Subject: RE: [PHP] Problem with date How about a little debugging here (and possibly elsewhere): if (isset($pubdate) ($pubdate 0)) { $pubdate=strtotime($pubdate); } else { die(Barf. Can't run a string to time conversion on 0 or -1.); } Thanks Kevin, This bombs and gives me the BARF! FYI the date field is stored in a MySQL DB as a datetime type -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with date
-Original Message- From: Jack [mailto:jacklistm...@gmail.com] 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 =2ba 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\$outbr; echo font size=2$descbrbr; # echo font size=1 class=rss-linkThis 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
Re: [PHP] Problem with DATE 2010-10-31
On 12/10/2010 11:52, Rado Oršula wrote: I do not know good English. In the attached source code. Here is erroneous statement: date: 2010-10-31 00:00:00 date+*0*h: 2010-10-31 *00*:00:00 date+*1*h: 2010-10-31 *01*:00:00 *date+2h: 2010-10-31 02:00:00 date+3h: 2010-10-31 02:00:00 * date+*4*h: 2010-10-31 *03*:00:00 [snip] probably at that time the Daylight Savings Time change kicks in ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with DATE 2010-10-31
On 12 October 2010 10:52, Rado Oršula rado.ors...@gmail.com wrote: I do not know good English. In the attached source code. Here is erroneous statement: date: 2010-10-31 00:00:00 date+0h: 2010-10-31 00:00:00 date+1h: 2010-10-31 01:00:00 date+2h: 2010-10-31 02:00:00 date+3h: 2010-10-31 02:00:00 date+4h: 2010-10-31 03:00:00 date+5h: 2010-10-31 04:00:00 date+6h: 2010-10-31 05:00:00 date+7h: 2010-10-31 06:00:00 date+8h: 2010-10-31 07:00:00 date+9h: 2010-10-31 08:00:00 date+10h: 2010-10-31 09:00:00 date+11h: 2010-10-31 10:00:00 date+12h: 2010-10-31 11:00:00 date+13h: 2010-10-31 12:00:00 date+14h: 2010-10-31 13:00:00 date+15h: 2010-10-31 14:00:00 date+16h: 2010-10-31 15:00:00 date+17h: 2010-10-31 16:00:00 date+18h: 2010-10-31 17:00:00 date+19h: 2010-10-31 18:00:00 date+20h: 2010-10-31 19:00:00 date+21h: 2010-10-31 20:00:00 date+22h: 2010-10-31 21:00:00 date+23h: 2010-10-31 22:00:00 date+24h: 2010-10-31 23:00:00 What timezone are you in? In the UK GMT's BST is about to end and revert to standard GMT (If D.R. reads this I apologize for the wishy washy explanation). So, if you were to include the DST, the output would look right. date+0h: 2010-10-31 00:00:00 BST date+1h: 2010-10-31 01:00:00 BST date+2h: 2010-10-31 02:00:00 BST date+3h: 2010-10-31 02:00:00 GMT date+4h: 2010-10-31 03:00:00 GMT date+5h: 2010-10-31 04:00:00 GMT date+6h: 2010-10-31 05:00:00 GMT -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with date
Adding the number of seconds in a day could fall in the same day due to daylight saving time, a more reliable way of adding one day (or a given number of days) is this: $tomorrow = mktime(0, 0, 0, date(m) , date(d)+1, date(Y)); Then use date() with $tomorrow to format it. (Taken from example #3 here: http://www.php.net/manual/en/function.date.php, see the Note below the example in that page). Hope that helps. Regards, Jonathan 2009/9/15 Korgan josber...@seznam.cz: Hi, I have a problem with date function. $gen_pos = mktime(0,0,1,10,25,2009); $d1 = date(Y-m-d, $gen_pos); // 2009-10-25 $d2 = date(Y-m-d, $gen_pos + (1*24*60*60)); // 2009-10-25 $d3 = date(Y-m-d, $gen_pos + (2*24*60*60)); // 2009-10-26 $d4 = date(Y-m-d, $gen_pos + (3*24*60*60)); // 2009-10-27 $d5 = date(Y-m-d, $gen_pos + (4*24*60*60)); $d6 = date(Y-m-d, $gen_pos + (5*24*60*60)); $d7 = date(Y-m-d, $gen_pos + (6*24*60*60)); $d8 = date(Y-m-d, $gen_pos + (7*24*60*60)); line 2 and line 3 return same date,its wrong ... it should be 2009-10-25 , 2009-10-26 ? :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with date
strtotime would be a neater way of solving the problem... ie (untested): $n = 0; while ($n = 9) { $date = d.$n; $$date = date(Y-m-d, strtotime(+ $n days) $n++; } If you are just enquiring about the maths though, I'm not sure! -Original Message- From: Korgan [mailto:josber...@seznam.cz] Sent: 15 September 2009 16:32 To: php-general@lists.php.net Subject: [PHP] Problem with date Hi, I have a problem with date function. $gen_pos = mktime(0,0,1,10,25,2009); $d1 = date(Y-m-d, $gen_pos);// 2009-10-25 $d2 = date(Y-m-d, $gen_pos + (1*24*60*60)); // 2009-10-25 $d3 = date(Y-m-d, $gen_pos + (2*24*60*60)); // 2009-10-26 $d4 = date(Y-m-d, $gen_pos + (3*24*60*60)); // 2009-10-27 $d5 = date(Y-m-d, $gen_pos + (4*24*60*60)); $d6 = date(Y-m-d, $gen_pos + (5*24*60*60)); $d7 = date(Y-m-d, $gen_pos + (6*24*60*60)); $d8 = date(Y-m-d, $gen_pos + (7*24*60*60)); line 2 and line 3 return same date,its wrong ... it should be 2009-10-25 , 2009-10-26 ? :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with date('w')
I have a problem with the date function ? $theday = date(Y-m-d, time()); echo date((w), $theday); ? I'm pretty sure the optional second argument for date is a unix timestamp that you would generate by using either time or mktime or strtotime. You are passing it something in the form of Y-m-d, or 2003-08-23 when it is expecting 1061852640. http://www.php.net/manual/en/function.date.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with date('w')
i found out that using strtotime did the trick !! ? strtotime($theday); $theday = date(Y-m-d, time()); echo date((w), $theday); ? I have a problem with the date function ? $theday = date(Y-m-d, time()); echo date((w), $theday); ? I'm pretty sure the optional second argument for date is a unix timestamp that you would generate by using either time or mktime or strtotime. You are passing it something in the form of Y-m-d, or 2003-08-23 when it is expecting 1061852640. http://www.php.net/manual/en/function.date.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem on Date Function
On Tuesday 03 June 2003 17:40, Jack wrote: q: how i can do a date subtraction in php? (eg. 2003-06-02 - 3 = 2003-05-30) strtotime() -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The law will never make men free; it is men who have got to make the law free. -- Henry David Thoreau */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with Date (2003-03-30)
-Original Message- From: Gareth Mulholland [mailto:[EMAIL PROTECTED]] I'm having problems with mktime and Midnight on 30th March 2003. The code I'm using is: echo mktime(0,0,1,'03','29','2003'); echo mktime(0,0,1,'03','30','2003'); echo mktime(0,0,1,'03','31','2003'); but the result is: 1048896001 -3661 1049065201 I ran your exact code and got this: 1048921201 1049007601 1049094001 Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Date (2003-03-30)
All parameters whould be integers. Unquote them and use intval to strip the leading zeros. On 1/29/03 11:51, Gareth Mulholland [EMAIL PROTECTED] wrote: I'm having problems with mktime and Midnight on 30th March 2003. The code I'm using is: echo mktime(0,0,1,'03','29','2003'); echo mktime(0,0,1,'03','30','2003'); echo mktime(0,0,1,'03','31','2003'); but the result is: 1048896001 -3661 1049065201 Therefore date is giving me 31 Dec 1969. Is this a problem with UNIX or PHP? Thanks Gareth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php