Click here to Skip to main content
15,905,686 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have two field related to an employee:

$enter and $leave ('08:00' and '18:00').

What I want to know, is that if that person is working "now" at current minute.

How can I handle this?

I did it this way:

PHP
$x = "18:00";
$y = "22:00";

//list($hour_enter,$minute_enter)= split('[:]', $x);
list($hour_leave,$minute_leave)= split('[:]', $y);

date_default_timezone_set('Europe/Lisbon');

$now= gmdate("H");
$z = $hour_leave-$now;

if($z > 0)
    echo "he's still working";
else
    echo "he already left";
Posted
Updated 1-Jun-11 10:22am
v2
Comments
Sergey Alexandrovich Kryukov 1-Jun-11 15:25pm    
What do you try so far?
--SA
Maxdd 7 1-Jun-11 16:23pm    
Updated my answer. I just asked because I supposed there was a method to do that (lately I found there was a php method for everything :)

I'm supposing now I was wrong, so please consider my question "solved".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900