Re: [PHP] Date/time format?
2007. 03. 30, péntek keltezéssel 14.00-kor Jason Pruim ezt írta: On Mar 29, 2007, at 4:52 PM, Zoltán Németh wrote: snip (I assume you want this calculation within one given day) you could read all rows into an array like $timeinfo = array(); $sql = SELECT minute, sequence FROM table WHERE day='$day'; $result = mysql_query($result); while ($row = mysql_fetch_assoc($result)) { $timeinfo[$row['sequence'] = $row['minute']; } and then calculate and echo the difference between any element of the array: $diff0_1 = $timeinfo[1] - $timeinfo[0]; $timeinfo[$row['sequence'] = $row['minute']; --- is the [ between $timeinfo and $row a typo? or is there supposed to be a closing ] somewhere? yeah it should be closed, sorry for the typo. this way: $timeinfo[$row['sequence']] = $row['minute']; greets Zoltán Németh When I add a closing ] to it as such: $timeinfo[$row['sequence'] = $row['minute']]; I get this error when I try and open the page: [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined index: minute in /Volumes/RAIDer/webserver/Documents/tests/oatstest/ oatstime.php on line 15 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined index: in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 15 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined offset: 1 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 18 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined offset: 0 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 18 Line 15 is this line: $timeinfo[$row['sequence'] = $row['minute']]; and line 18 has: $diff0_1 = $timeinfo[1] - $timeinfo[0]; What I am trying to do is subtract $timeinfo[1] from $timeinfo[0] and then display the difference. When I echo $timeinfo it just says array so my thinking is that the errors are caused by the array not being populated properly based on the extra [ or a missing ]. Am I at least on the right track? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
On Mar 29, 2007, at 6:16 PM, Jim Lucas wrote: you stated in a different email that there are 6 possible values/ settings for the sequence col. what are they, and what do they mean? One person asked about missed punches. What happens if someone forgets to clock out? Is an entry made for the person for the appropriate day/minutes/sequence ??? I can see a way to do what you are asking, but I need these questions answered first. Okay, here's what I have figured out about how the original programmer did it. Employees are given the option of using a clock in/clock out link on the web page or entering the hours manually. Most of the employees just sign in/out at the end of the day. The sequence number is used to keep it in order so that it can do the math based on the right day. sequence 0 is the first sign in, sequence 1 is the first sign out, sequence 2 is the second sign in, sequence 3 is the second sign out etc. etc.. Basically if an employee works from 8:00 AM until 4:30 PM with a half hour lunch the database would look something like this: Sequence 0 480 (8 AM) IN Sequence 1 720 (12 noon) OUT Sequence 2 750 (12:30) IN Sequence 3 990 (4:30) OUT Or if they work until 7 PM with a break for lunch and supper it would look like: Sequence 0 480 (8 AM) IN Sequence 1 720 (12 noon) OUT Sequence 2 750 (12:30) IN Sequence 3 990 (4:30) OUT Sequence 4 1020 (5PM) IN Sequence 5 1140 (7PM) OUT The idea being if you sort by employee, day, and then sequence you can do the math by subtracting sequence 0 from sequence 1, sequence 2 from sequence 3 etc. etc. When I started looking at this originally, I was just looking at adding a feature to it, but now I'm thinking that since I've learned a fair amount about working with databases, I may try and write my own as a side project to learn even more :) I will try the suggestions that were given and any new ones that come in and see what works best, and when I do that I'll post the results back here for posterity. Thanks everyone for your help! It's because of people like you that I have been able to come as far as I have in this world. -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com “Give me your tired, your poor, Your huddled masses yearning to breathe free, The wretched refuse of your teeming shore. Send these, the homeless tempest-tost to me, I lift my lamp beside the golden door!” From “The New Colossus,” by Emma Lazarus smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] Date/time format?
On Mar 29, 2007, at 4:52 PM, Zoltán Németh wrote: snip (I assume you want this calculation within one given day) you could read all rows into an array like $timeinfo = array(); $sql = SELECT minute, sequence FROM table WHERE day='$day'; $result = mysql_query($result); while ($row = mysql_fetch_assoc($result)) { $timeinfo[$row['sequence'] = $row['minute']; } and then calculate and echo the difference between any element of the array: $diff0_1 = $timeinfo[1] - $timeinfo[0]; $timeinfo[$row['sequence'] = $row['minute']; --- is the [ between $timeinfo and $row a typo? or is there supposed to be a closing ] somewhere? When I add a closing ] to it as such: $timeinfo[$row['sequence'] = $row['minute']]; I get this error when I try and open the page: [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined index: minute in /Volumes/RAIDer/webserver/Documents/tests/oatstest/ oatstime.php on line 15 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined index: in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 15 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined offset: 1 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 18 [Fri Mar 30 13:55:36 2007] [error] PHP Notice: Undefined offset: 0 in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on line 18 Line 15 is this line: $timeinfo[$row['sequence'] = $row['minute']]; and line 18 has: $diff0_1 = $timeinfo[1] - $timeinfo[0]; What I am trying to do is subtract $timeinfo[1] from $timeinfo[0] and then display the difference. When I echo $timeinfo it just says array so my thinking is that the errors are caused by the array not being populated properly based on the extra [ or a missing ]. Am I at least on the right track? -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com We hold these truths to be self-evident. That all men are created equal, that they are endowed by their creator with certain unalienable rights, (and) that among these are Life, Liberty, and the pursuit of Happiness. smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] Date/time format?
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 | the minutes column is the number of minutes that have passed since midnight. the sequence number refers to the sequence that the times were entered, meaning that 480 minutes after midnight came before 720 minutes, which was before 750 minutes which was before 990 minutes. What I need to do, is be able to calculate the time between 0 1, 2 3, 4 5 (there is a total of 6 sequences that could be in here) here is now the math would like on that particular entry: (480-720) + (750-990)=480/60=8 hours. This is a timecard program that I'm trying to write a report for to show the time for the entire month instead of it's default for the week. You can see what I have tried live at: raoset.com/tests/ oatstest/oats.shtml the code that I need help with is the math. I have looked but I just can't find a clear way to get the info from mysql, into an array in php to do the math? Maybe I've been looking at it to long and so I'm missing easy stuff? I have tried this code: $querytime = mysql_query(select sum(minutes) as t1, sum(sequence) as t2 from oats_time); while($row = mysql_fetch_array($querytime)){ $fulltotal=$row['t1']+$row['t2']; echo($fulltotal); } but that didn't work the way I wanted it to. Anyway... Post is long enough to start, so let me know if there is other info you need. Thanks in advance! -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com America will never be destroyed from the outside. If we falter and lose our freedoms, it will be because we destroyed ourselves. -Abraham Lincoln smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] Date/time format?
2007. 03. 29, csütörtök keltezéssel 16.38-kor Jason Pruim ezt írta: 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 | the minutes column is the number of minutes that have passed since midnight. the sequence number refers to the sequence that the times were entered, meaning that 480 minutes after midnight came before 720 minutes, which was before 750 minutes which was before 990 minutes. What I need to do, is be able to calculate the time between 0 1, 2 3, 4 5 (there is a total of 6 sequences that could be in here) here is now the math would like on that particular entry: (480-720) + (750-990)=480/60=8 hours. This is a timecard program that I'm trying to write a report for to show the time for the entire month instead of it's default for the week. You can see what I have tried live at: raoset.com/tests/ oatstest/oats.shtml the code that I need help with is the math. I have looked but I just can't find a clear way to get the info from mysql, into an array in php to do the math? Maybe I've been looking at it to long and so I'm missing easy stuff? I have tried this code: $querytime = mysql_query(select sum(minutes) as t1, sum(sequence) as t2 from oats_time); while($row = mysql_fetch_array($querytime)){ $fulltotal=$row['t1']+$row['t2']; echo($fulltotal); } but that didn't work the way I wanted it to. Anyway... Post is long enough to start, so let me know if there is other info you need. (I assume you want this calculation within one given day) you could read all rows into an array like $timeinfo = array(); $sql = SELECT minute, sequence FROM table WHERE day='$day'; $result = mysql_query($result); while ($row = mysql_fetch_assoc($result)) { $timeinfo[$row['sequence'] = $row['minute']; } and then calculate and echo the difference between any element of the array: $diff0_1 = $timeinfo[1] - $timeinfo[0]; greets Zoltán Németh Thanks in advance! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Roberto Mansfield wrote: 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. He doesn't have the option of changing this, it is a pre existing system. He is just trying to add a feature. -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Jason Pruim wrote: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com “Give me your tired, your poor, Your huddled masses yearning to breathe free, The wretched refuse of your teeming shore. Send these, the homeless tempest-tost to me, I lift my lamp beside the golden door!” From “The New Colossus,” by Emma Lazarus you stated in a different email that there are 6 possible values/settings for the sequence col. what are they, and what do they mean? One person asked about missed punches. What happens if someone forgets to clock out? Is an entry made for the person for the appropriate day/minutes/sequence ??? I can see a way to do what you are asking, but I need these questions answered first. -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Jason Pruim wrote: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 Could it be Feb 18, 2007 ?? If so, then that is just the unix timestamp. echo date('r', 1171774800); more data functions at: http://www.php.net/date -B I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) -- Jason Pruim [EMAIL PROTECTED] Production Technology Manager MQC Specialist (2005 certified) 3251 132nd Ave Holland MI 49424 616.399.2355 www.raoset.com “Give me your tired, your poor, Your huddled masses yearning to breathe free, The wretched refuse of your teeming shore. Send these, the homeless tempest-tost to me, I lift my lamp beside the golden door!” From “The New Colossus,” by Emma Lazarus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Jason Pruim wrote: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 Looks like epoch time. Use date(Y-m-d,$epochtime); to get a standard date string out of it. www.php.net/date/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
2007. 03. 28, szerda keltezéssel 15.35-kor Jason Pruim ezt írta: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) what does strtotime return for that string? greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
Zoltán Németh wrote: 2007. 03. 28, szerda keltezéssel 15.35-kor Jason Pruim ezt írta: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) what does strtotime return for that string? It's already a time, strtotime should return FALSE. It probably can't parse that string to a time. Travis D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date/time format?
Jason wrote: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) That is a UNIX timestamp, which is the type of date that the php date() function takes as a 2nd parameter. So for example, ?php echo date(m/d/Y, $row['day']) // Output: 02/18/2007 ? You can also format it in the query like so: mysql SELECT FROM_UNIXTIME(day) AS theDate FROM myTable; Output: 2007-02-18 00:00:00 If you want to insert new records in the table you can either use time() in php, or UNIX_TIMESTAMP(NOW()) in the query. HTH, -B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date/time format?
2007. 03. 28, szerda keltezéssel 14.48-kor Travis Doherty ezt írta: Zoltán Németh wrote: 2007. 03. 28, szerda keltezéssel 15.35-kor Jason Pruim ezt írta: Hi Everyone, First off, I'm using PHP 5.2.0 and apache 1.3.33 I am trying to figure out what format a string is in in a database. It's a timecard system that I have found on-line and I am attempting to figure out how to write a script that would give me everyones timecard for the month on one screen I can print out for accounting to use. Below is an example of one of the lines in the database, What I'm really interested in is how it represents the day. user dayjob_name minutes sequence root 1171774800 Production technology Manager 990 3 I have not been able to find ANY info about that format, other then other people using it in blogs. I think I can figure out the rest as I go if I know how to decode the day. Any help or pointers to the M would be GREATLY appreciated! :) what does strtotime return for that string? It's already a time, strtotime should return FALSE. It probably can't parse that string to a time. sorry I meant strftime ;) greets Zoltán Németh Travis D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php