Date: 07/26/02
- Next message: Mitja Stepan: "[PHP] Re: (newbie) questions abot vars and args"
- Previous message: Tech Support: "Re: [PHP] php redirect"
- In reply to: Steve Bradwell: "[PHP] time question."
- Next in thread: Steve Bradwell: "RE: [PHP] time question."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> How do I compare time in php?
>
> Eg. If I have a mysql time field I retrieve stored in $result[0][0] how do
I
> say :
>
> if (($result[0][0] > $result[0][0] plus ten minutes) && ($result[0][0] >
> '00:00:00')){
MySQL and PHP timestamps are in different formats. MySQL uses YYYYMMDDHHMMSS
and PHP uses a unix timestamp, the number of seconds since January 1st,
1970.
You can use UNIXTIMESTAMP(your_column) in your query to get a PHP style unix
timestamp.
Although, if you explain what you are trying to do a little better, you
could probably do the comparisons a lot easier in your query and not involve
PHP at all.
SELECT * FROM your_table WHERE your_column > your_column + INTERVAL 10
MINUTE AND your_column != 0
That looks equivilent to what you're trying to do in PHP. You might have to
say your_column+0 != 0 to get your_column as an integer and not a string.
---John Holmes...
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Mitja Stepan: "[PHP] Re: (newbie) questions abot vars and args"
- Previous message: Tech Support: "Re: [PHP] php redirect"
- In reply to: Steve Bradwell: "[PHP] time question."
- Next in thread: Steve Bradwell: "RE: [PHP] time question."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

