Re: date problems: my, php, or mysql issue?

From: Date: Mon, 28 Aug 2000 17:47:06 +0000
Subject: Re: date problems: my, php, or mysql issue?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-2422@lists.php.net to get a copy of this message
Hi Jason, It would seem one could gain demi-guru status if he/she could handle all the date problems. Non-guru comments, see below. Jason Murray wrote: > _snip_ > +---------+-------------+------+-----+-------------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +---------+-------------+------+-----+-------------+----------------+ > | id | smallint(5) | | PRI | 0 | auto_increment | > | name | varchar(50) | | | has no name | | > | started | date | | | 1000-01-01 | | > | stopped | date | | | 1000-01-01 | | > +---------+-------------+------+-----+-------------+----------------+ You might gain some advantages by using NULL for the default in the Default field. Can't summon up the will to look into that. Just a recollection. > > mysql> select * from tbl_employees; > 7 rows in set (0.00 sec) > > +----+----------------+------------+------------+ > | id | name | started | stopped | > +----+----------------+------------+------------+ > | 1 | Jason Murray | 2000-08-21 | 1000-01-01 | > | 2 | Mark Felicelli | 2000-04-09 | 1000-01-01 | > | 3 | Joe Koenig | 2000-01-22 | 1000-01-01 | > | 4 | Jim Comparato | 1999-02-11 | 1000-01-01 | > | 5 | Amy Comparato | 1999-02-11 | 1000-01-01 | > | 6 | Butthead | 2000-02-11 | 2000-08-23 | > | 7 | Beavis | 2000-02-15 | 2000-08-23 | > +----+----------------+------------+------------+ > ========================================================================= Have you tried using the mysql functions to handle this, instead of handling it all in prog logic? Maybe something like: WHERE (TO_DAYS(CURRENT_DATE) - TO_DAYS(started)) There's even a FLOOR function and a whole group of other date functions. Shirley there's one to handle the DST problem. And, in your code, you might be having an apples and organges thing. Timestamp vs localtime (in your time init function), being where the DST prob might be showing up. Maybe using trying the mysql date functions would help sort this out. (and I think this is where using null as your default for stopped field will show up). Mike D. / Lost in Time II

« previous php.db (#2422) next »