asking help

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
irvine
Forum Newbie
Posts: 14
Joined: Sat Jul 26, 2003 3:04 am

asking help

Post by irvine »

hi,

Example
John is a staff of AA Company. He started to join the AA company in 1999 until now 2003. Then he wants to take a leave start from 25/7/2003 to 31/7/2003 for holiday.

Format
- a new staff with a two years worked have basic leave is 18 days.
- Start from 3 years worked a staff has additional leave 1 day. That is means after 2 years worked a staff will have an additional leave 1 day for 1 year.
- E.g. john had worked at AA company 4 years already (2003 – 1999 = 4 years). That’s mean john has 21 days leave (18+3). After john take the leaves and balance is 14 days (21-7=14)

Question
1.) how can I write a PHP code for the year to count the leave?

* before that I can count the balance without the year. Straight count the duration and minus it then get the balance (balance = 18 – duration). But now I don’t know how to do already. I hope u can help and guide me.

thank you.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

I would convert the relevant dates into UNIX-timestamps using mktime(), then do all the necessary arithmetics and convert the results back from UNIX-timestamps to a "normal" data using date().
irvine
Forum Newbie
Posts: 14
Joined: Sat Jul 26, 2003 3:04 am

Post by irvine »

sorry here first, i dont understand how to using mktime but heard the timestamp before. can u show me more clearly?

thank you
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

1. stop cross-posting (you started, what, 4 posts regarding this?). This is annoying and confusing.
2. read up on the functions linked to in my post above. The user notes are especially relevant. You may also want to look at strftime(). There are many examples in the manual on how to use these functions.
3. if you have some code done already, post it.
Post Reply