Calculating total hours
Posted: 2019-04-24 11:39
Hello, I'm Mustafa and I'm from The Netherlands, first introduction for you all.
I played with AppGini Demo for several days and finally bought it and it feels great!
Ahmed is very kind and his service on replying mails is 100% fine.
I'm working on a Timesheet project, just to play around with PHP and MySQL.
I got 5 tables, one of them is workinghours, most important fields are: workingday (datum), starttime (starttijd), lunchtime (pauze), endtime (eindtijd), weeknumber (weeknummer) and totalhours (totaaltijd).
With the hooks-function I got it so far that the weeknumber is calculated, based on the workingday:
If I calculate the totaltime without lunchtime calculation, the totaltime is fine:
If I calculate the totaltime minus the lunchtime, then the output is always 11:19:32, based on 8 hours work minus any lunchtime:
Can somebody tell me what I'm doing wrong, I'm not a programmer, mostly I search and adjust code of someone else 
I played with AppGini Demo for several days and finally bought it and it feels great!
Ahmed is very kind and his service on replying mails is 100% fine.
I'm working on a Timesheet project, just to play around with PHP and MySQL.
I got 5 tables, one of them is workinghours, most important fields are: workingday (datum), starttime (starttijd), lunchtime (pauze), endtime (eindtijd), weeknumber (weeknummer) and totalhours (totaaltijd).
With the hooks-function I got it so far that the weeknumber is calculated, based on the workingday:
Code: Select all
$date = new DateTime($data['Datum']);
$data['Weeknummer'] = $date->format("W");
Code: Select all
date_default_timezone_set("Europe/Amsterdam");
$data['Totaaltijd'] = $data['Starttijd'] && $data['Eindtijd'] ? gmdate('H:i:s', (strtotime($data['Eindtijd'])-strtotime($data['Starttijd']))) : '';
Code: Select all
date_default_timezone_set("Europe/Amsterdam");
$data['Totaaltijd'] = $data['Starttijd'] && $data['Eindtijd'] && $data['Pauze'] ? gmdate('H:i:s' , (strtotime($data['Eindtijd'])-strtotime($data['Starttijd']))-strtotime($data['Pauze'])) : '';
