Re: Time Calcuations

From: Date: Thu, 16 Oct 2003 04:36:28 +0000
Subject: Re: Time Calcuations
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-166273@lists.php.net to get a copy of this message
Jake McHenry wrote:
Here's my problem: In my time calculations, I'm taking the time that the user clocked out, minus the time they clocked in. I'm using the time_to_sec function in mysql. I work very odd hours. If I clock in say at 10pm, then clock out at 1am, the clock is majorly messed up. I think it's because it's a new day. I thought that the time_to_sec functon turned the time into seconds from 1980 or something like that, so the date and time when returning to the function should be right...
Use a complete timestamp for the two times. That'll include a complete date and time that the worker clocked in and out. You can then convert them to unix timestamps, subtract them, and use sec_to_time() to determine the hours when it's needed. SUM() that up with a WHERE condition to limit the dates to the current week and you'll know how many hours you worked. Or just store it in unix timestamp format to begin with. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#166273) next »