Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
im making a mini attendance module, but i dont have a idea to do this so please help me and the user must attend every 3hrs so if they attend at 3:05 the difference from time will be the value of $late

this is my code of getting the time to show in the page

PHP
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10){
minutes = "0" + minutes
}
document.write(hours + ":" + minutes + " ")
if(hours > 11){
document.write("PM")
} else {
document.write("AM")
}

so im planning to get the time into the database by using this

PHP
INSERT INTO time_in(late,time_in)
        VALUES ('$late,NOW())";

and my big problem is how can i get the difference from time required to they time attend and inserted into my database

What I have tried:

i really dont know how to do this
Posted
Updated 6-Feb-17 20:36pm
Comments
Mohibur Rashid 7-Feb-17 2:33am    
The first code block does not look like php, it's look like javascript

For php try this link
http://php.net/manual/en/datetime.diff.php
For javascript try this
http://stackoverflow.com/questions/1787939/check-time-difference-in-javascript
For mysql try this
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

Member 12986530 7-Feb-17 2:55am    
yes its a javascript

its just to tell the user what time it is and

1 solution

 
Share this answer
 

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