[thelist] date time calculation query

Renoir Boulanger renoirb at gmail.com
Tue Sep 20 17:29:36 CDT 2011


This is easy Bob.

The numbers are not integers but what we call UniX Epoch timestamps. In other words... seconds since January 1st 1970 00:00:00. If i am not mistaken.

In fact, as I recall, this is the common ground fordates on every POSIX compliant system and to my opibion the best way to store a date.

Generally PHP lets you use it with strftime and the modifier "U". Not sure exactly by heart how. Frameworks has helpers for this such has DateHelper.php in symfony 1.4 or Date Object format string method.


hope this helps

RENOIR BOULANGER //

devLABmtl.org/
ConFoo.ca/
evocatio.com/

(envoyé de mon téléphone)
~

On 2011-09-20, at 17:58, Bob Meetin <bobm at dottedi.biz> wrote:

> I am writing a query against an existing database/table in which I need to qualify whether the member's subscription is active. Typically when I write these types of queries the 2 dates are in some date type, but here they are int(11) and I presume that the number is relevant to some date from point in time, but of course I'm unfamiliar with this method of doing calculations.
> 
> The values:
> 
> +----+---------+---------------+------------------+----------------+
> | id | user_id | membership_id | membership_start | membership_end |
> +----+---------+---------------+------------------+----------------+
> |  1 |      62 |             2 |       1316571958 |     1319163958 |
> |  2 |      62 |             1 |       1316572508 |     1319164508 |
> +----+---------+---------------+------------------+----------------+
> 2 rows in set (1.23 sec)
> 
> The relevant fields:
> 
> mysql> desc membership_users;
> +---------------------+---------------+------+-----+---------+----------------+
> | Field               | Type          | Null | Key | Default | Extra          |
> +---------------------+---------------+------+-----+---------+----------------+
> | id                  | int(11)       | NO   | PRI | NULL    | auto_increment |
> | user_id             | int(11)       | NO   | MUL | NULL    |                |
> | membership_id       | int(11)       | NO   |     | NULL    |                |
> | membership_start    | int(11)       | NO   |     | NULL    |                |
> | membership_end      | int(11)       | NO   |     | NULL    |                |
> +---------------------+---------------+------+-----+---------+----------------+
> 
> Given the user_id I need to determine if the current date/time is between the start/end and if so, set some variable in PHP to TRUE, say $access = TRUE.  Advice please...
> 
> -- 
> Bob
> 
> -- 
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt ! 


More information about the thelist mailing list