datetime conversion

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

datetime conversion

Post by jauson »

Hi,

Currently im developing a payroll system now, but im getting a hard time how to calculate datetime from our attendance sheet (biometrics).. I do have connection to import our existing software which is our biometrics going to php mysql database. my problem is I do not have an idea how to calculate their attendance.

example

ID DEPARTMENT NAME EMPLOYEEID DATE/TIME
1 IT JON 100011 2012-04-02 06:00:00 aM
2 IT JON 100011 2012-04-02 06:00:00 PM


how do i manage their attendance or compute DATETIME field to get exactly salaries,


any ideas?

REGARDS ALL,
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: datetime conversion

Post by requinix »

You want... the number of days since the date? Or what?
jauson
Forum Contributor
Posts: 111
Joined: Wed Oct 05, 2011 12:59 am

Re: datetime conversion

Post by jauson »

I want to calculate datetime to hours or days. for example
2012-04-02 06:00:00 aM
2012-04-02 06:00:00 PM
Result 1 days and/or 12 hours,
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: datetime conversion

Post by requinix »

Here is a good place to look for a MySQL answer. I see two functions in there that will do it.

For a PHP answer it depends whether you have PHP 5.3 or not.
jauson
Forum Contributor
Posts: 111
Joined: Wed Oct 05, 2011 12:59 am

Re: datetime conversion

Post by jauson »

what is that functions?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: datetime conversion

Post by requinix »

DATEDIFF() and TIMEDIFF(). One for the number of days, the other for the number of hours.
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Re: datetime conversion

Post by litebearer »

@ requinix - I can see how timediff would work with the datetime in and datetime out in the same table row; however, OP seems to have times in and times out in different rows, Could you show example query how one could use that mysql function given the way the OP's data is setup?

OR would OP need to 'grab' data from each row as timestamp then subtract the two?
Post Reply