Re: date time problem
| From: | Jim Giner | Date: | Mon, 07 Oct 2013 01:10:56 +0000 |
| Subject: | Re: date time problem | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322255@lists.php.net to get a copy of this 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.dalaee@gmail.com>wrote: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.Its so freaky Best Regards Farzan DalaeeOn Oct 7, 2013, at 2:29, Jim Giner <jim.giner@albanyhandball.com> wrote:wrote:On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate("H:i:s", $diff%86400) Best Regards Farzan DalaeeOn Oct 7, 2013, at 2:12, Jim Giner <jim.giner@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 DalaeeOn Oct 7, 2013, at 1:49, Jim Giner <jim.giner@albanyhandball.com>even close until an hour or two goes by....I always hate dealing with date/time stuff in php - never get itthis right?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 getGMT? However, I did try it, changing the 'time_left' calc to use "gmdate". Now instead of a 7 for hours I have a 12.Thanks for the quick response, but why do I want to show the time in-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpDoesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpexp 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