php-general Digest 7 Oct 2013 13:24:41 -0000 Issue 8388

Topics (messages 322243 through 322257):

Re: date time problem
        322243 by: Farzan Dalaee
        322244 by: Jim Giner
        322245 by: Farzan Dalaee
        322247 by: Jim Giner
        322248 by: Farzan Dalaee
        322249 by: Jonathan Sundquist
        322250 by: Aziz Saleh
        322251 by: Jim Giner
        322252 by: Aziz Saleh
        322253 by: Ashley Sheridan
        322254 by: Jim Giner
        322255 by: Jim Giner
        322256 by: Romain CIACCAFAVA

After a PHP script timeout, Apache logs the error but may not cleanly exit the 
script
        322246 by: Meta Seller Admin

PHP Fatal error: Call to undefined function ()
        322257 by: Michael Alaimo

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 ---
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee

> On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com> wrote:
> 
> I always hate dealing with date/time stuff in php - never get it even close 
> until an hour or two goes by....
> 
> anyway
> 
> I have this:
> 
> // get two timestamp values
> $exp_time = $_COOKIE[$applid."expire"];
> $curr_time = time();
> // get the difference
> $diff = $exp_time - $curr_time;
> // produce a display time of the diff
> $time_left = date("h:i:s",$diff);
> 
> Currently the results are:
> exp_time is 06:55:07
> curr_time is 06:12:03
> the diff is 2584
> All of these are correct.
> 
> BUT time_left is 07:43:04 when it should be only "00:43:04".
> 
> So - where is the hour value of '07' coming from?? And how do I get this 
> right?
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee

On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com> wrote:

I always hate dealing with date/time stuff in php - never get it even close 
until an hour or two goes by....

anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get this right?

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


Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use "gmdate". Now instead of a 7 for hours I have a 12.

exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

--- End Message ---
--- Begin Message ---
Try this please

 gmdate("H:i:s", $diff%86400) 

Best Regards
Farzan Dalaee

> On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com> wrote:
> 
>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>> You should use  gmdate() if you want to how many hours left to expire
>> $time_left = gmdate("H:i:s",$diff);
>> 
>> Best Regards
>> Farzan Dalaee
>> 
>>> On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com> wrote:
>>> 
>>> I always hate dealing with date/time stuff in php - never get it even close 
>>> until an hour or two goes by....
>>> 
>>> anyway
>>> 
>>> I have this:
>>> 
>>> // get two timestamp values
>>> $exp_time = $_COOKIE[$applid."expire"];
>>> $curr_time = time();
>>> // get the difference
>>> $diff = $exp_time - $curr_time;
>>> // produce a display time of the diff
>>> $time_left = date("h:i:s",$diff);
>>> 
>>> Currently the results are:
>>> exp_time is 06:55:07
>>> curr_time is 06:12:03
>>> the diff is 2584
>>> All of these are correct.
>>> 
>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>>> 
>>> So - where is the hour value of '07' coming from?? And how do I get this 
>>> right?
>>> 
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
> Thanks for the quick response, but why do I want to show the time in GMT?  
> However, I did try it, changing the 'time_left' calc to use "gmdate".  Now 
> instead of a 7 for hours I have a 12.
> 
> exp 07:34:52
> curr 06:40:14
> diff 3158
> left is 12:52:38
> 
> The 52:38 is the correct value, but not the 12.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
Try this please

  gmdate("H:i:s", $diff%86400)

Best Regards
Farzan Dalaee

On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com> wrote:

On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee

On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com> wrote:

I always hate dealing with date/time stuff in php - never get it even close 
until an hour or two goes by....

anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get this right?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thanks for the quick response, but why do I want to show the time in GMT?  However, I did 
try it, changing the 'time_left' calc to use "gmdate".  Now instead of a 7 for 
hours I have a 12.

exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

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


Doesn't work either.

--- End Message ---
--- Begin Message ---
Its so freaky 

Best Regards
Farzan Dalaee

> On Oct 7, 2013, at 2:29, Jim Giner <jim.gi...@albanyhandball.com> wrote:
> 
>> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
>> Try this please
>> 
>>  gmdate("H:i:s", $diff%86400)
>> 
>> Best Regards
>> Farzan Dalaee
>> 
>>>> On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com> wrote:
>>>> 
>>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>>>> You should use  gmdate() if you want to how many hours left to expire
>>>> $time_left = gmdate("H:i:s",$diff);
>>>> 
>>>> Best Regards
>>>> Farzan Dalaee
>>>> 
>>>>> On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com> wrote:
>>>>> 
>>>>> I always hate dealing with date/time stuff in php - never get it even 
>>>>> close until an hour or two goes by....
>>>>> 
>>>>> anyway
>>>>> 
>>>>> I have this:
>>>>> 
>>>>> // get two timestamp values
>>>>> $exp_time = $_COOKIE[$applid."expire"];
>>>>> $curr_time = time();
>>>>> // get the difference
>>>>> $diff = $exp_time - $curr_time;
>>>>> // produce a display time of the diff
>>>>> $time_left = date("h:i:s",$diff);
>>>>> 
>>>>> Currently the results are:
>>>>> exp_time is 06:55:07
>>>>> curr_time is 06:12:03
>>>>> the diff is 2584
>>>>> All of these are correct.
>>>>> 
>>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>>>>> 
>>>>> So - where is the hour value of '07' coming from?? And how do I get this 
>>>>> right?
>>>>> 
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>> Thanks for the quick response, but why do I want to show the time in GMT?  
>>> However, I did try it, changing the 'time_left' calc to use "gmdate".  Now 
>>> instead of a 7 for hours I have a 12.
>>> 
>>> exp 07:34:52
>>> curr 06:40:14
>>> diff 3158
>>> left is 12:52:38
>>> 
>>> The 52:38 is the correct value, but not the 12.
>>> 
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
> Doesn't work either.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
This should help you out
http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php
On Oct 6, 2013 6:07 PM, "Farzan Dalaee" <farzan.dal...@gmail.com> wrote:

> Its so freaky
>
> Best Regards
> Farzan Dalaee
>
> > On Oct 7, 2013, at 2:29, Jim Giner <jim.gi...@albanyhandball.com> wrote:
> >
> >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
> >> Try this please
> >>
> >>  gmdate("H:i:s", $diff%86400)
> >>
> >> Best Regards
> >> Farzan Dalaee
> >>
> >>>> On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com>
> wrote:
> >>>>
> >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
> >>>> You should use  gmdate() if you want to how many hours left to expire
> >>>> $time_left = gmdate("H:i:s",$diff);
> >>>>
> >>>> Best Regards
> >>>> Farzan Dalaee
> >>>>
> >>>>> On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com>
> wrote:
> >>>>>
> >>>>> I always hate dealing with date/time stuff in php - never get it
> even close until an hour or two goes by....
> >>>>>
> >>>>> anyway
> >>>>>
> >>>>> I have this:
> >>>>>
> >>>>> // get two timestamp values
> >>>>> $exp_time = $_COOKIE[$applid."expire"];
> >>>>> $curr_time = time();
> >>>>> // get the difference
> >>>>> $diff = $exp_time - $curr_time;
> >>>>> // produce a display time of the diff
> >>>>> $time_left = date("h:i:s",$diff);
> >>>>>
> >>>>> Currently the results are:
> >>>>> exp_time is 06:55:07
> >>>>> curr_time is 06:12:03
> >>>>> the diff is 2584
> >>>>> All of these are correct.
> >>>>>
> >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
> >>>>>
> >>>>> So - where is the hour value of '07' coming from?? And how do I get
> this right?
> >>>>>
> >>>>> --
> >>>>> PHP General Mailing List (http://www.php.net/)
> >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>> Thanks for the quick response, but why do I want to show the time in
> GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
>  Now instead of a 7 for hours I have a 12.
> >>>
> >>> exp 07:34:52
> >>> curr 06:40:14
> >>> diff 3158
> >>> left is 12:52:38
> >>>
> >>> The 52:38 is the correct value, but not the 12.
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> > Doesn't work either.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>

--- End Message ---
--- Begin Message ---
Jim,

The date method takes in a timestamp (not seconds away).

You have the seconds, you will need to manually convert those seconds to
what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..

Aziz


On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee <farzan.dal...@gmail.com>wrote:

> Its so freaky
>
> Best Regards
> Farzan Dalaee
>
> > On Oct 7, 2013, at 2:29, Jim Giner <jim.gi...@albanyhandball.com> wrote:
> >
> >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
> >> Try this please
> >>
> >>  gmdate("H:i:s", $diff%86400)
> >>
> >> Best Regards
> >> Farzan Dalaee
> >>
> >>>> On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com>
> wrote:
> >>>>
> >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
> >>>> You should use  gmdate() if you want to how many hours left to expire
> >>>> $time_left = gmdate("H:i:s",$diff);
> >>>>
> >>>> Best Regards
> >>>> Farzan Dalaee
> >>>>
> >>>>> On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com>
> wrote:
> >>>>>
> >>>>> I always hate dealing with date/time stuff in php - never get it
> even close until an hour or two goes by....
> >>>>>
> >>>>> anyway
> >>>>>
> >>>>> I have this:
> >>>>>
> >>>>> // get two timestamp values
> >>>>> $exp_time = $_COOKIE[$applid."expire"];
> >>>>> $curr_time = time();
> >>>>> // get the difference
> >>>>> $diff = $exp_time - $curr_time;
> >>>>> // produce a display time of the diff
> >>>>> $time_left = date("h:i:s",$diff);
> >>>>>
> >>>>> Currently the results are:
> >>>>> exp_time is 06:55:07
> >>>>> curr_time is 06:12:03
> >>>>> the diff is 2584
> >>>>> All of these are correct.
> >>>>>
> >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
> >>>>>
> >>>>> So - where is the hour value of '07' coming from?? And how do I get
> this right?
> >>>>>
> >>>>> --
> >>>>> PHP General Mailing List (http://www.php.net/)
> >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>> Thanks for the quick response, but why do I want to show the time in
> GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
>  Now instead of a 7 for hours I have a 12.
> >>>
> >>> exp 07:34:52
> >>> curr 06:40:14
> >>> diff 3158
> >>> left is 12:52:38
> >>>
> >>> The 52:38 is the correct value, but not the 12.
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> > Doesn't work either.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>

--- End Message ---
--- Begin Message ---
Look at my code. The inputs are all timestamps so date should work, no?
My question why am i getting an hour value in this case?

jg


On Oct 6, 2013, at 7:14 PM, Aziz Saleh <azizsa...@gmail.com> wrote:

> Jim,
> 
> The date method takes in a timestamp (not seconds away).
> 
> You have the seconds, you will need to manually convert those seconds to what 
> you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
> 
> Aziz
> 
> 
> On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee <farzan.dal...@gmail.com> wrote:
>> Its so freaky
>> 
>> Best Regards
>> Farzan Dalaee
>> 
>> > On Oct 7, 2013, at 2:29, Jim Giner <jim.gi...@albanyhandball.com> wrote:
>> >
>> >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
>> >> Try this please
>> >>
>> >>  gmdate("H:i:s", $diff%86400)
>> >>
>> >> Best Regards
>> >> Farzan Dalaee
>> >>
>> >>>> On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com> wrote:
>> >>>>
>> >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>> >>>> You should use  gmdate() if you want to how many hours left to expire
>> >>>> $time_left = gmdate("H:i:s",$diff);
>> >>>>
>> >>>> Best Regards
>> >>>> Farzan Dalaee
>> >>>>
>> >>>>> On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com> 
>> >>>>> wrote:
>> >>>>>
>> >>>>> I always hate dealing with date/time stuff in php - never get it even 
>> >>>>> close until an hour or two goes by....
>> >>>>>
>> >>>>> anyway
>> >>>>>
>> >>>>> I have this:
>> >>>>>
>> >>>>> // get two timestamp values
>> >>>>> $exp_time = $_COOKIE[$applid."expire"];
>> >>>>> $curr_time = time();
>> >>>>> // get the difference
>> >>>>> $diff = $exp_time - $curr_time;
>> >>>>> // produce a display time of the diff
>> >>>>> $time_left = date("h:i:s",$diff);
>> >>>>>
>> >>>>> Currently the results are:
>> >>>>> exp_time is 06:55:07
>> >>>>> curr_time is 06:12:03
>> >>>>> the diff is 2584
>> >>>>> All of these are correct.
>> >>>>>
>> >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>> >>>>>
>> >>>>> So - where is the hour value of '07' coming from?? And how do I get 
>> >>>>> this right?
>> >>>>>
>> >>>>> --
>> >>>>> PHP General Mailing List (http://www.php.net/)
>> >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>> Thanks for the quick response, but why do I want to show the time in 
>> >>> GMT?  However, I did try it, changing the 'time_left' calc to use 
>> >>> "gmdate".  Now instead of a 7 for hours I have a 12.
>> >>>
>> >>> exp 07:34:52
>> >>> curr 06:40:14
>> >>> diff 3158
>> >>> left is 12:52:38
>> >>>
>> >>> The 52:38 is the correct value, but not the 12.
>> >>>
>> >>> --
>> >>> PHP General Mailing List (http://www.php.net/)
>> >>> To unsubscribe, visit: http://www.php.net/unsub.php
>> > Doesn't work either.
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
> 

--- End Message ---
--- Begin Message ---
The resulting subtraction is not a valid timestamp, but rather the
difference between the two timestamps in seconds . The resulting diff can
be 1 if the timestamps are 1 seconds apart. The
link<http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php>Jonathan
sent out contains functions that does the division for you with
results. Another link you can check out:

http://stackoverflow.com/a/9143387/1935500



On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:

> Look at my code. The inputs are all timestamps so date should work, no?
> My question why am i getting an hour value in this case?
>
> jg
>
>
> On Oct 6, 2013, at 7:14 PM, Aziz Saleh <azizsa...@gmail.com> wrote:
>
> Jim,
>
> The date method takes in a timestamp (not seconds away).
>
> You have the seconds, you will need to manually convert those seconds to
> what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
>
> Aziz
>
>
> On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee <farzan.dal...@gmail.com>wrote:
>
>> Its so freaky
>>
>> Best Regards
>> Farzan Dalaee
>>
>> > On Oct 7, 2013, at 2:29, Jim Giner <jim.gi...@albanyhandball.com>
>> wrote:
>> >
>> >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
>> >> Try this please
>> >>
>> >>  gmdate("H:i:s", $diff%86400)
>> >>
>> >> Best Regards
>> >> Farzan Dalaee
>> >>
>> >>>> On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com>
>> wrote:
>> >>>>
>> >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>> >>>> You should use  gmdate() if you want to how many hours left to expire
>> >>>> $time_left = gmdate("H:i:s",$diff);
>> >>>>
>> >>>> Best Regards
>> >>>> Farzan Dalaee
>> >>>>
>> >>>>> On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com>
>> wrote:
>> >>>>>
>> >>>>> I always hate dealing with date/time stuff in php - never get it
>> even close until an hour or two goes by....
>> >>>>>
>> >>>>> anyway
>> >>>>>
>> >>>>> I have this:
>> >>>>>
>> >>>>> // get two timestamp values
>> >>>>> $exp_time = $_COOKIE[$applid."expire"];
>> >>>>> $curr_time = time();
>> >>>>> // get the difference
>> >>>>> $diff = $exp_time - $curr_time;
>> >>>>> // produce a display time of the diff
>> >>>>> $time_left = date("h:i:s",$diff);
>> >>>>>
>> >>>>> Currently the results are:
>> >>>>> exp_time is 06:55:07
>> >>>>> curr_time is 06:12:03
>> >>>>> the diff is 2584
>> >>>>> All of these are correct.
>> >>>>>
>> >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>> >>>>>
>> >>>>> So - where is the hour value of '07' coming from?? And how do I get
>> this right?
>> >>>>>
>> >>>>> --
>> >>>>> PHP General Mailing List (http://www.php.net/)
>> >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>> Thanks for the quick response, but why do I want to show the time in
>> GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
>>  Now instead of a 7 for hours I have a 12.
>> >>>
>> >>> exp 07:34:52
>> >>> curr 06:40:14
>> >>> diff 3158
>> >>> left is 12:52:38
>> >>>
>> >>> The 52:38 is the correct value, but not the 12.
>> >>>
>> >>> --
>> >>> PHP General Mailing List (http://www.php.net/)
>> >>> To unsubscribe, visit: http://www.php.net/unsub.php
>> > Doesn't work either.
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>>
>
>

--- End Message ---
--- Begin Message ---
On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote:

> Jim,
> 
> The date method takes in a timestamp (not seconds away).
> 
> You have the seconds, you will need to manually convert those seconds to
> what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
> 
> Aziz
> 
> 
> On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee <farzan.dal...@gmail.com>wrote:
> 
> > Its so freaky
> >
> > Best Regards
> > Farzan Dalaee
> >
> > > On Oct 7, 2013, at 2:29, Jim Giner <jim.gi...@albanyhandball.com> wrote:
> > >
> > >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
> > >> Try this please
> > >>
> > >>  gmdate("H:i:s", $diff%86400)
> > >>
> > >> Best Regards
> > >> Farzan Dalaee
> > >>
> > >>>> On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com>
> > wrote:
> > >>>>
> > >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
> > >>>> You should use  gmdate() if you want to how many hours left to expire
> > >>>> $time_left = gmdate("H:i:s",$diff);
> > >>>>
> > >>>> Best Regards
> > >>>> Farzan Dalaee
> > >>>>
> > >>>>> On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com>
> > wrote:
> > >>>>>
> > >>>>> I always hate dealing with date/time stuff in php - never get it
> > even close until an hour or two goes by....
> > >>>>>
> > >>>>> anyway
> > >>>>>
> > >>>>> I have this:
> > >>>>>
> > >>>>> // get two timestamp values
> > >>>>> $exp_time = $_COOKIE[$applid."expire"];
> > >>>>> $curr_time = time();
> > >>>>> // get the difference
> > >>>>> $diff = $exp_time - $curr_time;
> > >>>>> // produce a display time of the diff
> > >>>>> $time_left = date("h:i:s",$diff);
> > >>>>>
> > >>>>> Currently the results are:
> > >>>>> exp_time is 06:55:07
> > >>>>> curr_time is 06:12:03
> > >>>>> the diff is 2584
> > >>>>> All of these are correct.
> > >>>>>
> > >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
> > >>>>>
> > >>>>> So - where is the hour value of '07' coming from?? And how do I get
> > this right?
> > >>>>>
> > >>>>> --
> > >>>>> PHP General Mailing List (http://www.php.net/)
> > >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
> > >>> Thanks for the quick response, but why do I want to show the time in
> > GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
> >  Now instead of a 7 for hours I have a 12.
> > >>>
> > >>> exp 07:34:52
> > >>> curr 06:40:14
> > >>> diff 3158
> > >>> left is 12:52:38
> > >>>
> > >>> The 52:38 is the correct value, but not the 12.
> > >>>
> > >>> --
> > >>> PHP General Mailing List (http://www.php.net/)
> > >>> To unsubscribe, visit: http://www.php.net/unsub.php
> > > Doesn't work either.
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >


Aziz, please try not to top post :)

It's true that the date() function takes in a timestamp as its argument,
but a timestamp is a number representing the number of seconds since
00:00:00 1st January 1970, so passing in a very small number of seconds
is perfectly valid.

The only thing that would account for the 7 hours difference is the time
zone, which would also be part of the timestamp.
http://en.wikipedia.org/wiki/Unix_time gives more details.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On 10/6/2013 7:40 PM, Aziz Saleh wrote:
The resulting subtraction is not a valid timestamp, but rather the
difference between the two timestamps in seconds . The resulting diff can
be 1 if the timestamps are 1 seconds apart. The
link<http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php>Jonathan
sent out contains functions that does the division for you with
results. Another link you can check out:

http://stackoverflow.com/a/9143387/1935500



On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:

Look at my code. The inputs are all timestamps so date should work, no?
My question why am i getting an hour value in this case?

jg


On Oct 6, 2013, at 7:14 PM, Aziz Saleh <azizsa...@gmail.com> wrote:

Jim,

The date method takes in a timestamp (not seconds away).

You have the seconds, you will need to manually convert those seconds to
what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..

Aziz


On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee <farzan.dal...@gmail.com>wrote:

Its so freaky

Best Regards
Farzan Dalaee

On Oct 7, 2013, at 2:29, Jim Giner <jim.gi...@albanyhandball.com>
wrote:

On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
Try this please

  gmdate("H:i:s", $diff%86400)

Best Regards
Farzan Dalaee

On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com>
wrote:

On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee

On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com>
wrote:

I always hate dealing with date/time stuff in php - never get it
even close until an hour or two goes by....

anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get
this right?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thanks for the quick response, but why do I want to show the time in
GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
  Now instead of a 7 for hours I have a 12.

exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Doesn't work either.

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





Good Point! I never looked at it that way. I guess the Date function can't be relied on in that case. So now I'll have to calculate my time in a mathematical way instead of letting Date translate it for me.

Thanks!



--- End Message ---
--- Begin Message ---
On 10/6/2013 7:55 PM, Ashley Sheridan wrote:
On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote:

Jim,

The date method takes in a timestamp (not seconds away).

You have the seconds, you will need to manually convert those seconds to
what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..

Aziz


On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee <farzan.dal...@gmail.com>wrote:

Its so freaky

Best Regards
Farzan Dalaee

On Oct 7, 2013, at 2:29, Jim Giner <jim.gi...@albanyhandball.com> wrote:

On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
Try this please

  gmdate("H:i:s", $diff%86400)

Best Regards
Farzan Dalaee

On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com>
wrote:

On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee

On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com>
wrote:

I always hate dealing with date/time stuff in php - never get it
even close until an hour or two goes by....

anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get
this right?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thanks for the quick response, but why do I want to show the time in
GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
  Now instead of a 7 for hours I have a 12.

exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Doesn't work either.

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




Aziz, please try not to top post :)

It's true that the date() function takes in a timestamp as its argument,
but a timestamp is a number representing the number of seconds since
00:00:00 1st January 1970, so passing in a very small number of seconds
is perfectly valid.

The only thing that would account for the 7 hours difference is the time
zone, which would also be part of the timestamp.
http://en.wikipedia.org/wiki/Unix_time gives more details.

Thanks,
Ash
http://www.ashleysheridan.co.uk



Thanks Ash, but the previous (top) post explained my dilemma just as you have done here. My attempt to use a function to avoid "doing the math" has now been resolved. Guess I'll have to do it the old-fashioned way.
--- End Message ---
--- Begin Message ---
An easier way to do that would be using the diff() method of a DateTime object 
on another.

Regards
Romain Ciaccafava

> Le 7 oct. 2013 à 03:10, Jim Giner <jim.gi...@albanyhandball.com> a écrit :
> 
>> On 10/6/2013 7:55 PM, Ashley Sheridan wrote:
>>> On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote:
>>> 
>>> Jim,
>>> 
>>> The date method takes in a timestamp (not seconds away).
>>> 
>>> You have the seconds, you will need to manually convert those seconds to
>>> what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
>>> 
>>> Aziz
>>> 
>>> 
>>> On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee 
>>> <farzan.dal...@gmail.com>wrote:
>>> 
>>>> Its so freaky
>>>> 
>>>> Best Regards
>>>> Farzan Dalaee
>>>> 
>>>>>> On Oct 7, 2013, at 2:29, Jim Giner <jim.gi...@albanyhandball.com> wrote:
>>>>>> 
>>>>>> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
>>>>>> Try this please
>>>>>> 
>>>>>>  gmdate("H:i:s", $diff%86400)
>>>>>> 
>>>>>> Best Regards
>>>>>> Farzan Dalaee
>>>>>> 
>>>>>>>> On Oct 7, 2013, at 2:12, Jim Giner <jim.gi...@albanyhandball.com>
>>>> wrote:
>>>>>>>> 
>>>>>>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>>>>>>>> You should use  gmdate() if you want to how many hours left to expire
>>>>>>>> $time_left = gmdate("H:i:s",$diff);
>>>>>>>> 
>>>>>>>> Best Regards
>>>>>>>> Farzan Dalaee
>>>>>>>> 
>>>>>>>>> On Oct 7, 2013, at 1:49, Jim Giner <jim.gi...@albanyhandball.com>
>>>> wrote:
>>>>>>>>> 
>>>>>>>>> I always hate dealing with date/time stuff in php - never get it
>>>> even close until an hour or two goes by....
>>>>>>>>> 
>>>>>>>>> anyway
>>>>>>>>> 
>>>>>>>>> I have this:
>>>>>>>>> 
>>>>>>>>> // get two timestamp values
>>>>>>>>> $exp_time = $_COOKIE[$applid."expire"];
>>>>>>>>> $curr_time = time();
>>>>>>>>> // get the difference
>>>>>>>>> $diff = $exp_time - $curr_time;
>>>>>>>>> // produce a display time of the diff
>>>>>>>>> $time_left = date("h:i:s",$diff);
>>>>>>>>> 
>>>>>>>>> Currently the results are:
>>>>>>>>> exp_time is 06:55:07
>>>>>>>>> curr_time is 06:12:03
>>>>>>>>> the diff is 2584
>>>>>>>>> All of these are correct.
>>>>>>>>> 
>>>>>>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>>>>>>>>> 
>>>>>>>>> So - where is the hour value of '07' coming from?? And how do I get
>>>> this right?
>>>>>>>>> 
>>>>>>>>> --
>>>>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>>> Thanks for the quick response, but why do I want to show the time in
>>>> GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
>>>>  Now instead of a 7 for hours I have a 12.
>>>>>>> 
>>>>>>> exp 07:34:52
>>>>>>> curr 06:40:14
>>>>>>> diff 3158
>>>>>>> left is 12:52:38
>>>>>>> 
>>>>>>> The 52:38 is the correct value, but not the 12.
>>>>>>> 
>>>>>>> --
>>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>> Doesn't work either.
>>>>> 
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
>> Aziz, please try not to top post :)
>> 
>> It's true that the date() function takes in a timestamp as its argument,
>> but a timestamp is a number representing the number of seconds since
>> 00:00:00 1st January 1970, so passing in a very small number of seconds
>> is perfectly valid.
>> 
>> The only thing that would account for the 7 hours difference is the time
>> zone, which would also be part of the timestamp.
>> http://en.wikipedia.org/wiki/Unix_time gives more details.
>> 
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
> Thanks Ash, but the previous (top) post explained my dilemma just as you have 
> done here.  My attempt to use a function to avoid "doing the math" has now 
> been resolved.  Guess I'll have to do it the old-fashioned way.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
Hi. I'm wondering if anyone can help with this.

We're using PHP and Apache, hosted on a dedicated server running
Debian Linux. The specific versions in each case are mostly
immaterial, as this problem has been around since Debian 6, and is
still present in Debian 7; in the meantime we've been using the latest
versions of all packages.

We're having problems with PHP script timeouts, which although rare,
are behaving erratically and causing severe problems when they do
occur.

The timeouts are always recorded in the Apache log, and sometimes the
script and everything else may execute/terminate correctly, but often,
various failures may be observed, such as:

* timeouts not registered back to PHP - the script may not terminate
as expected (the function registered with register_shutdown_function()
- see code example below - may not be called);

* after a timeout, Apache may run in the background indefinitely,
using up CPU resources in one core;

* Apache may fail altogether - no further requests serviced - Apache
must be restarted.

The exact cause of the fault has not been found. It is reproducible on
all servers we deploy to.

Example PHP script:

//...
function _on_shutdown()
{
    if (connection_status() & CONNECTION_TIMEOUT)
    {
        echo 'ERROR: TIMEOUT!';
        //Do something else...
    }
    exit;
}
register_shutdown_function('_on_shutdown');
//...more code here...
//(various potentially long running scripts which may timeout)


The above was also posted here:
http://serverfault.com/questions/542045/after-a-php-script-timeout-apache-logs-the-error-but-may-not-cleanly-exit-the-s

Ric.

--- End Message ---
--- Begin Message ---
We have a server that gets a large number of requests each month.

After a period of time I began to see this error in our error logs this
weekend.

PHP Fatal error:  Call to undefined function ()

It does not reference a function, so I found it odd.  It did give a line to
a function with array_merge on it.

Has anyone seen this in the apache error logs?  We are using PHP 5.3.3.

Mike

--- End Message ---

Reply via email to