php-general Digest 30 Dec 2011 15:34:33 -0000 Issue 7629

Topics (messages 316125 through 316130):

Re: Question about date calculations
        316125 by: Frank Arensmeier
        316126 by: Fatih P.
        316127 by: admin.buskirkgraphics.com
        316128 by: Fatih P.
        316129 by: Lester Caine

More Error Reporting Problems
        316130 by: Floyd Resler

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
29 dec 2011 kl. 22.22 skrev Eric Lommatsch:

> So far in looking at the functions that are available at
> http://www.php.net/manual/en/ref.datetime.php I have not been able to figure
> out how to do what I need to do.  Below is a snippet showing approximately
> what I am trying to do.

On the same page you are referring, there are plenty of examples on how to 
calculate the difference between two dates. Choose one and see if it fits your 
bill. Or is there any particular reason why you're writing your "own" function?

http://www.php.net/manual/en/ref.datetime.php#78981

/frank


--- End Message ---
--- Begin Message ---
On Thu, Dec 29, 2011 at 11:40 PM, Frank Arensmeier <farensme...@gmail.com>wrote:

> 29 dec 2011 kl. 22.22 skrev Eric Lommatsch:
>
> > So far in looking at the functions that are available at
> > http://www.php.net/manual/en/ref.datetime.php I have not been able to
> figure
> > out how to do what I need to do.  Below is a snippet showing
> approximately
> > what I am trying to do.
>
> On the same page you are referring, there are plenty of examples on how to
> calculate the difference between two dates. Choose one and see if it fits
> your bill. Or is there any particular reason why you're writing your "own"
> function?
>
> http://www.php.net/manual/en/ref.datetime.php#78981
>
> /frank
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
since you have everything in database tables why not to do this calculation
on database side which would be much appropriate place ?

/* columns
date_start = '2011-02-08';
date_end = ' 2011-03-04';
*/

select DATEDIFF(date_end, date_start);

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_datediff

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Fatih P. [mailto:fatihpirist...@gmail.com]
> Sent: Thursday, December 29, 2011 5:10 PM
> To: Frank Arensmeier
> Cc: Eric Lommatsch; php-gene...@lists.php.net
> Subject: Re: [PHP] Question about date calculations
> 
> On Thu, Dec 29, 2011 at 11:40 PM, Frank Arensmeier
> <farensme...@gmail.com>wrote:
> 
> > 29 dec 2011 kl. 22.22 skrev Eric Lommatsch:
> >
> > > So far in looking at the functions that are available at
> > > http://www.php.net/manual/en/ref.datetime.php I have not been able
> to
> > figure
> > > out how to do what I need to do.  Below is a snippet showing
> > approximately
> > > what I am trying to do.
> >
> > On the same page you are referring, there are plenty of examples on
> how to
> > calculate the difference between two dates. Choose one and see if it
> fits
> > your bill. Or is there any particular reason why you're writing your
> "own"
> > function?
> >
> > http://www.php.net/manual/en/ref.datetime.php#78981
> >
> > /frank
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> since you have everything in database tables why not to do this
> calculation
> on database side which would be much appropriate place ?
> 
> /* columns
> date_start = '2011-02-08';
> date_end = ' 2011-03-04';
> */
> 
> select DATEDIFF(date_end, date_start);
> 
> http://dev.mysql.com/doc/refman/5.5/en/date-and-time-
> functions.html#function_datediff


I looked at this answer and see the date is from an array of a database and not 
2 fields with in the table.
While the DATEDIFF() is very useful in queries this will not help you unless 
both fields are in the table.

Try this example

$dteStartDate[$intCnt] = new DateTime($row[10]);
$dteEndDate[$intCnt] =new DateTime($row[11]);
$interval = $dteStartDate[$intCnt]->diff($dteEndDate[$intCnt]);
echo $interval->format('%R%a days');


 






--- End Message ---
--- Begin Message ---


On 12/30/2011 12:19 AM, ad...@buskirkgraphics.com wrote:
-----Original Message-----
From: Fatih P. [mailto:fatihpirist...@gmail.com]
Sent: Thursday, December 29, 2011 5:10 PM
To: Frank Arensmeier
Cc: Eric Lommatsch; php-gene...@lists.php.net
Subject: Re: [PHP] Question about date calculations

On Thu, Dec 29, 2011 at 11:40 PM, Frank Arensmeier
<farensme...@gmail.com>wrote:

29 dec 2011 kl. 22.22 skrev Eric Lommatsch:

So far in looking at the functions that are available at
http://www.php.net/manual/en/ref.datetime.php I have not been able
to
figure
out how to do what I need to do.  Below is a snippet showing
approximately
what I am trying to do.
On the same page you are referring, there are plenty of examples on
how to
calculate the difference between two dates. Choose one and see if it
fits
your bill. Or is there any particular reason why you're writing your
"own"
function?

http://www.php.net/manual/en/ref.datetime.php#78981

/frank


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


since you have everything in database tables why not to do this
calculation
on database side which would be much appropriate place ?

/* columns
date_start = '2011-02-08';
date_end = ' 2011-03-04';
*/

select DATEDIFF(date_end, date_start);

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-
functions.html#function_datediff

I looked at this answer and see the date is from an array of a database and not 
2 fields with in the table.
While the DATEDIFF() is very useful in queries this will not help you unless 
both fields are in the table.

Try this example

$dteStartDate[$intCnt] = new DateTime($row[10]);
$dteEndDate[$intCnt] =new DateTime($row[11]);
$interval = $dteStartDate[$intCnt]->diff($dteEndDate[$intCnt]);
echo $interval->format('%R%a days');

well then look deeper in the question:

"I have a page I am trying to create where I am comparing the values of two
MySQL date fields with the current date. One of the *MySQL Date fields *is a class start date,*the other* is the class end date."

all needs to do is modify his query.


--- End Message ---
--- Begin Message ---
Fatih P. wrote:
well then look deeper in the question:

"I have a page I am trying to create where I am comparing the values of two
MySQL date fields with the current date. One of the *MySQL Date fields *is a
class start date,*the other* is the class end date."

all needs to do is modify his query.

And by moving the lookup into the query then Eric only needs to return the rows of the table that are in range ...

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
I'm still  having problems with error reporting and I'm not sure why.  This is 
the section in my php.ini file:
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = On
log_errors = On
error_log = /var/log/php_errors.log

Errors are neither getting displayed nor recorded in my error log.  I can't 
spot anything wrong in the configuration file.  Anyone have any ideas?  I can 
post my configuration file if needed.

Thanks!
Floyd


--- End Message ---

Reply via email to