Re: Date problem with new year

From: Date: Wed, 02 Jan 2002 22:12:39 +0000
Subject: Re: Date problem with new year
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-15319@lists.php.net to get a copy of this message
Sorry for the delay... include --enable-calendar in the php compilation. On Wed, 2 Jan 2002, Faye Keesic wrote: > Okay, when I try to change the gregorian date to julian, I get > error: call to undefined function: gregoriantojd() in line... > > Here's the code I used to replace $datetoget=($datetoget-1); > > //from what I understand ,must be in month, day, year format > //so passed today's date > $greg_date=GregorianToJD(1,2,2002); > //subtracted a day > $greg_date=($greg_date-1); > //converted it back to gregorian format > $datetoget=JDToGregorian($greg_date); > -- > Faye Keesic > Computer Programmer Analyst/Web Page Design > > > > From: ted@php.net > > Date: Wed, 2 Jan 2002 07:55:02 -0800 (PST) > > To: Faye Keesic <fkeesic@fortfrances.com> > > Cc: php-db@lists.php.net > > Subject: Re: [PHP-DB] Date problem with new year > > > > Ah... the "$datetoget = ($datetoget-1)" is the problem. > > > > Convert the Gregorian Ymd date to Julian, subtract 1, then convert the > > Julian date back to Gregorian (or Hebrew ;->). I've not had much success > > with MySQL's date functions. > > > > On Wed, 2 Jan 2002, Faye Keesic wrote: > > > >> I had no problems with retrieving news stories from previous days before > >> 2002, and haven't changed any of my code. This site has been up for a year, > >> and I can't recall anything like this happening when 2001 rolled around. > >> > >> Please excuse the messy code, as this was the first php/db web site I > >> designed. I took out the formatting stuff... :) > >> > >>> From my php page, I call a function: > >> > >> get_most_recent_stories(date("Ymd")); > >> - which passes today's date, formatted for for the db > >> > >> In my code: > >> > >> - this is the function I call - which in turn calls the function below > >> (no_yesterdays_stories($datetoget) to subtract a day if there is no news > >> items for the current date, which then calls the same > >> get_most_recent_stories() function, but passes a "lower" date. Ideally, > >> these will loop until there are stories found for a certain day. > >> > >> > >> function get_most_recent_stories($datetoget) > >> > >> { > >> //Get the headlines, summaries and links to the story > >> db_connect(); > >> $sql = "SELECT * FROM tblStory WHERE (StoryDate=$datetoget)"; > >> $results = mysql_query($sql); > >> if ($results) { > >> if ($row = mysql_fetch_array($results)) { > >> echo $row[StorySum];} > >> while ($row = mysql_fetch_array($results)); > >> } > >> else { > >> no_yesterdays_stories($datetoget); } } > >> } > >> > >> function no_yesterdays_stories($datetoget) > >> > >> { > >> //query has returned no stories from yesterday (holiday, etc.) > >> //keep subtracting on day from yesterday's date until there are stories > >> found > >> $datetoget=($datetoget-1); > >> get_most_recent_stories($datetoget); > >> } > >> > >> -- > >> Faye Keesic > >> Computer Programmer Analyst/Web Page Design > >> > >> > >>> From: Rick Emery <remery@excel.com> > >>> Date: Wed, 2 Jan 2002 09:05:42 -0600 > >>> To: php-db@lists.php.net > >>> Subject: RE: [PHP-DB] Date problem with new year > >>> > >>> No bug, mate. > >>> > >>> Post your code so that we can help ya... > >>> > >>> -----Original Message----- > >>> From: Faye Keesic [mailto:fkeesic@fortfrances.com] > >>> Sent: Wednesday, January 02, 2002 8:56 AM > >>> To: php-db@lists.php.net > >>> Subject: [PHP-DB] Date problem with new year > >>> > >>> > >>> I have a db site that always displays the most recent occurrence of news > >>> stories.... > >>> > >>> The last occurrence of stories was last year (2001-12-31) and up to the new > >>> year rolling over, I had no difficulty subtracting days, etc. > >>> > >>> Is there a bug in Mysql? PHP that I don't know of.. > >>> > >>> Please help. > >>> > >>> > >>> -- > >>> PHP Database Mailing List (http://www.php.net/) > >>> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > >>> For additional commands, e-mail: php-db-help@lists.php.net > >>> To contact the list administrators, e-mail: php-list-admin@lists.php.net > >>> > >>> -- > >>> PHP Database Mailing List (http://www.php.net/) > >>> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > >>> For additional commands, e-mail: php-db-help@lists.php.net > >>> To contact the list administrators, e-mail: php-list-admin@lists.php.net > >> > >> > >> -- > >> PHP Database Mailing List (http://www.php.net/) > >> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > >> For additional commands, e-mail: php-db-help@lists.php.net > >> To contact the list administrators, e-mail: php-list-admin@lists.php.net > >> > >> > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.db (#15319) next »