Re: Date/time format?
| From: | Roberto Mansfield | Date: | Thu, 29 Mar 2007 21:26:06 +0000 |
| Subject: | Re: Date/time format? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251697@lists.php.net to get a copy of this message | ||
Jason Pruim wrote:
> Thanks everyone for your suggestions, it turns out it was a unix time
> stamp and I can get it to parse out a normal date now.
>
> Now... on to the harder part....
>
> What I am trying to do is learn... This is kind of just a pet project
> for me to figure out how I can do it. here is how the database is laid out:
>
> +-----------+------------+---------------------------------+---------+----------+
>
> | user | day |
> job_name | minutes | sequence |
> +-----------+------------+---------------------------------+---------+----------+
>
> | root | 1172466000 | Production & technology Manager | 480
> | 0 |
> | root | 1172466000 | Production & technology Manager | 720
> | 1 |
> | root | 1172466000 | Production & technology Manager | 750
> | 2 |
> | root | 1172466000 | Production & technology Manager | 990
> | 3 |
Your table has different types of records in it -- clock in, and clock
out. You are using order to assume which record is a start time and
which is an end time. This is very vague. Also what happens if you are
working late past midnight or someone forgets to clock out?
I think a better approach would be to have a "clock in" field
(timestamp) and a "clock out" field (another timestamp). That will
simplify things considerably. You can then calculate your time totals
with math on each record instead of across records:
select (clock_out - clock_in)/3600 AS hours_worked from table ...
Or: select sum((...)) etc.