Half day leave

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jauson
Forum Contributor
Posts: 111
Joined: Wed Oct 05, 2011 12:59 am

Half day leave

Post by jauson »

Hi Everyone,

How to calculate two dates with time differencial. Im having a difficulties how to manage this logic. I want the employee to apply a leave in half day. but the result will be like this.

first 4 hours is equivalent to 0.5
whole day is equivalent to 1.0

example working hours

8am to 12pm is 0.5
1pm to 5pm will equivalent to 0.5 also.

and 24 hours is equivalent to 1.0


for example:

12/01/2012 08:00am
12/01/2012 12:00pm

result is 0.5


12/10/2012 01:00pm
12/10/2012 5:00pm

result is 0.5

12/12/2012
12/12/2012

result is 1

12/25/2012 1:00pm
12/26/2012 5:00pm

result is 1.5

help will be appreciated.

:drunk:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Half day leave

Post by Christopher »

Seems like you could find the number of hours that a person worked with the values you show. You might need to do a first pass would be to add additional beginning/end of day entries for those ranges that span multiple days. Then you can divide the number of hour in each range by 8 to get the result values.
(#10850)
jauson
Forum Contributor
Posts: 111
Joined: Wed Oct 05, 2011 12:59 am

Re: Half day leave

Post by jauson »

can you explain further?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Half day leave

Post by Christopher »

Which part?
(#10850)
jauson
Forum Contributor
Posts: 111
Joined: Wed Oct 05, 2011 12:59 am

Re: Half day leave

Post by jauson »

when the employee applied for a leave. and they have 8 working hours.
for example John is 8am to 5 pm and he wants to apply on february 1, 2012 (vacation leave) but half day only so on my form.

he needs to fill up

date from: February 1 2012 8:00 AM
date to: February 1 2012 12: 00 PM
counts: .5

another example
Ellise wants to apply vacation leave on February 12 2012 and he wants to use his 8 working hours.

so on my form

date from: February 12 2012 00:00
date to: February 13 2012 00:00
counts: 1.0

thanks
Post Reply