php-general Digest 31 Dec 2011 13:53:18 -0000 Issue 7630

Topics (messages 316131 through 316139):

Re: Question about date calculations
        316131 by: Eric Lommatsch
        316132 by: Eric Lommatsch
        316135 by: Eric Lommatsch
        316136 by: Jim Lucas
        316137 by: admin.buskirkgraphics.com

Re: More Error Reporting Problems
        316133 by: Matt Graham
        316134 by: Floyd Resler

Error in portuguese translation of substr_compare
        316138 by: QI.VOLMAR QI

array
        316139 by: saeed ahmed

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 ---
Hello Frank,
 

As far as I know I am not doing anything in terms of trying to write or use my 
own function.  What I am trying to do is use what PHP provides.  

 

Thank you

 


Eric H. Lommatsch
Programmer
Pivotal Data Incorporated  
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927

 


www.pivotaldata.com 

 


er...@pivotaldata.com 

 

 
 
-----Original message-----
From: Frank Arensmeier <farensme...@gmail.com>
Sent: Thu 29-12-2011 15:25
To: Eric Lommatsch <er...@pivotaldata.net>; 
CC: php-gene...@lists.php.net; 
Subject: Re: [PHP] Question about date calculations

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 ---
When I try this method:

 

$interval = $dteStartDate[$intCnt]->diff($dteEndDate[$intCnt]); I get the 
following error when I run the page: 

" Fatal error : Call to undefined method DateTime::diff() in 
/var/www/evalHomeLime.php on line 254"   
 

 

Thank you

 


Eric H. Lommatsch
Programmer
Pivotal Data Incorporated  
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927

 


www.pivotaldata.com 

 


er...@pivotaldata.com 

 

 
 
-----Original message-----
From: ad...@buskirkgraphics.com
Sent: Thu 29-12-2011 16:07
To: 'Fatih P.' <fatihpirist...@gmail.com>; 'Frank Arensmeier' 
<farensme...@gmail.com>; 
CC: 'Eric Lommatsch' <er...@pivotaldata.net>; php-gene...@lists.php.net; 
Subject: RE: [PHP] Question about date calculations


> -----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 ---
Actually for what I need this is exactly what i was looking for.  I am 
converting an asp page that was calculating this difference using VBA functions 
and I was trying to duplicate things as they were in that page. 
 

 

Thank you

 


Eric H. Lommatsch
Programmer
Pivotal Data Incorporated  
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927

 


www.pivotaldata.com 

 


er...@pivotaldata.com 

 

 
 
-----Original message-----
From: Fatih P. <fatihpirist...@gmail.com>
Sent: Thu 29-12-2011 16:16
To: ad...@buskirkgraphics.com; 
CC: 'Frank Arensmeier' <farensme...@gmail.com>; 'Eric Lommatsch' 
<er...@pivotaldata.net>; php-gene...@lists.php.net; 
Subject: Re: [PHP] Question about date calculations



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 ---
On 12/29/2011 01:22 PM, Eric Lommatsch wrote:
Hello List,

I am using PHP version 5.2.6.

I am using PHP V5.3.3

In my setup, the following lines give me errors stating that PHP cannot convert the DateTime object to a string. I was able to get around the error by changing your code to the following.

   $intDayCnt=$dteEndDate[$i]-$dteStartDate[$i];

$intDayCnt = ( $dteEndDate[$i]->format('m') -
               $dteStartDate[$i]->format('m') );

Be sure to change the following line as well.
$dteCheckDate = date('U');

   if (($dteCheckDate>=($dteEndDate[$i]-7)&&
$dteCheckDate<=($dteEndDate[$i]+1))&&  $intDayCnt<16)

if (
     $dteCheckDate >= ( $dteEndDate[$i]->format('U') - (7*86400) )
     &&
     $dteCheckDate <= ( $dteEndDate[$i]->format('U') + (86400) )
     &&
     $intDayCnt < 16
   ) {

Eric Lommatsch.

--
Jim Lucas

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Eric Lommatsch [mailto:er...@pivotaldata.com] On Behalf Of Eric
> Lommatsch
> Sent: Friday, December 30, 2011 12:31 PM
> To: Fatih P.; ad...@buskirkgraphics.com
> Cc: 'Frank Arensmeier'; 'Eric Lommatsch'; php-gene...@lists.php.net
> Subject: RE: Re: [PHP] Question about date calculations
> 
> 
> Actually for what I need this is exactly what i was looking for.  I am
> converting an asp page that was calculating this difference using VBA
> functions and I was trying to duplicate things as they were in that
> page.
> 
> 
> 
> 
> Thank you
> 
> 
> 
> 
> Eric H. Lommatsch
> Programmer
> Pivotal Data Incorporated
> 2087 South Grant Street
> Denver, CO 80210
> Tel 303-777-8939 Ext 23
> Fax 888-282-9927
> 
> 
> 
> 
> www.pivotaldata.com
> 
> 
> 
> 
> er...@pivotaldata.com
> 
> 
> 
> 
> 
> -----Original message-----
> From: Fatih P. <fatihpirist...@gmail.com>
> Sent: Thu 29-12-2011 16:16
> To: ad...@buskirkgraphics.com;
> CC: 'Frank Arensmeier' <farensme...@gmail.com>; 'Eric Lommatsch'
> <er...@pivotaldata.net>; php-gene...@lists.php.net;
> Subject: Re: [PHP] Question about date calculations
> 
> 
> 
> 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.


Thank you Eric,

        Date conversion is a popular issue when converting the language from
one to the next. 
I prefer to manage any date filtering outside of MySQL because sometimes the
fields are not clean or formatted correctly, and the DATEDIFF() of MySQL
just fails.
This failure can be devastating when dealing with a MySQL replication setup.
I gauge the MySQL process against the PHP process and determine which is
faster and which do I have more effective controls in.
I have found I have better flexibility and control of date filtering in PHP.

But squirrels will be squirrels...


--- End Message ---
--- Begin Message ---
From: Floyd Resler <fres...@adex-intl.com>
> I'm still  having problems with error reporting and I'm not sure why.
> php.ini section:
> 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. 

Check that /var/log/php_errors.log exists and that the user that your
webserver is running as has permission to write to that file.  "touch
/var/log/php_errors.log && chown apache:apache /var/log/php_errors.log" as
root may work; modify user/group if necessary.  /var/log is always owned by
root and is 755, meaning that the webserver user doesn't have permission to
create that file if it doesn't exist.

-- 
Matt G / Dances With Crows
The Crow202 Blog:  http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see


--- End Message ---
--- Begin Message ---
On Dec 30, 2011, at 11:05 AM, Matt Graham wrote:

> From: Floyd Resler <fres...@adex-intl.com>
>> I'm still  having problems with error reporting and I'm not sure why.
>> php.ini section:
>> 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. 
> 
> Check that /var/log/php_errors.log exists and that the user that your
> webserver is running as has permission to write to that file.  "touch
> /var/log/php_errors.log && chown apache:apache /var/log/php_errors.log" as
> root may work; modify user/group if necessary.  /var/log is always owned by
> root and is 755, meaning that the webserver user doesn't have permission to
> create that file if it doesn't exist.
> 
Goodness, I can't believe I missed something as simple as file permissions!  
That's why they weren't getting written to the log!  I'm still not sure why 
they aren't displaying.  But as long as I have a place to find them I'm cool 
with that.

Thanks!
Floyd


--- End Message ---
--- Begin Message ---
I was read substr_compare description in portuguese language, an I
asked myself to test it, so after several test, I found that its
wrong.
The text is in Portuguese:
           "Se length é igual ou maior que o comprimento de main_str e
length é setado, substr_compare() imprime warning e retorna FALSE."

That is translated:
          "If length is equal or bigger than size of main_str and
length is setted, substr_compare() prints a warning and return FALSE"

The original is:
          If offset is equal to or greater than the length of main_str
or length is set and is less than 1, substr_compare() prints a warning
and returns FALSE.

--- End Message ---
--- Begin Message ---
how can you explain someone in a simplest and everyday use example of ARRAY.

--- End Message ---

Reply via email to