Re: date time problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <azizsaleh@xxxxxxxxx> 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.dalaee@xxxxxxxxx> wrote:
>> Its so freaky
>> 
>> Best Regards
>> Farzan Dalaee
>> 
>> > On Oct 7, 2013, at 2:29, Jim Giner <jim.giner@xxxxxxxxxxxxxxxxxx> 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.giner@xxxxxxxxxxxxxxxxxx> 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.giner@xxxxxxxxxxxxxxxxxx> 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
>> >
> 

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux