For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > November 2004 > Re: [PHP-DB] Something wierd with time() and curdate()









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Something wierd with time() and curdate()
Jason Wong

2004-11-01, 3:55 am

On Sunday 31 October 2004 22:45, Bobo Wieland wrote:
> There is something wierd going on over here...
>
> I have a date field, datum, in mysql that I cast to a timestamp and check
> against time(). If the datum value is more than one day old the table finds
> a new random row and sets the datum field to CURDATE(). Now, this has
> worked for two years now, but today the script suddenly finds a new random
> row each time the script is run...


Would this line have anything to with it? If not, post some concise code (see
below).

> mysql_data_s($result, rand(0,$rows));



> I've notice this just after 11 pm today.
> As I can see from some debugging time() allways returns a higher value than
> the timestamp + 86400... Have I missed something in this script for the
> last couple of years or is there a bug somewhere? Could it have something
> to do with the fact that we turned the time back one hour last night?
>
> This is the code btw:


Please *try* to isolate the problem and post CONCISE code which sufficiently
illustrates your problem. For example (for this particular problem) if you
suspect PHP is calculating the dates incorrectly then a few lines of code
showing the date calculations would be sufficient. If you suspect MySQL is
the culprit then a single query would be sufficient.

--
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-db
------------------------------------------
/*
"There are things that are so serious that you can only joke about them"
- Heisenberg
*/
Bobo Wieland

2004-11-01, 8:55 am

Thanks for trying to help me...

I just found out what the problem was... I use the number of seconds in a
day (86400) as a constant Yesterday there wasn't 60*60*24 seconds in a day
though... It was acctually 60*60*25 seconds... That's why the script flipped
out at 11 pm... Also, in the spring time when we change the time again there
will be 60*60*23 seconds... I think I'll live with this, since the script
won't generate any serious error...


thanks again

_bobo
dev@elstudion.com

----- Original Message -----
From: "Jason Wong" <php-db@gremlins.biz>
To: <php-db@lists.php.net>
Sent: Monday, November 01, 2004 11:14 AM
Subject: Re: [PHP-DB] Something wierd with time() and curdate()


> On Sunday 31 October 2004 22:45, Bobo Wieland wrote:
>
> Would this line have anything to with it? If not, post some concise code
> (see
> below).
>
>
>
>
> Please *try* to isolate the problem and post CONCISE code which
> sufficiently
> illustrates your problem. For example (for this particular problem) if you
> suspect PHP is calculating the dates incorrectly then a few lines of code
> showing the date calculations would be sufficient. If you suspect MySQL is
> the culprit then a single query would be sufficient.
>
> --
> 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-db
> ------------------------------------------
> /*
> "There are things that are so serious that you can only joke about them"
> - Heisenberg
> */
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com