This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » development » Feature requests » subtracting days from 2 dates
subtracting days from 2 dates [message #85181] Fri, 11 September 2009 13:25 Go to next message
benakacha  is currently offline benakacha
Messages: 18
Registered: August 2009
Junior Member

hello,
How can find the result of subtracting days from 2 dates
for exp 2009/09/11 - 2009/09/09 = 3 days
because I did
public function getNbjc ()
(
$ total = $ this-> getDatefinc () - $ this-> getDatedebutc ();

return $ total;
)

and it gives me the result of subtracting years alone!:!
Re: subtracting days from 2 dates [message #85185 is a reply to message #85181 ] Fri, 11 September 2009 14:31 Go to previous messageGo to next message
benakacha  is currently offline benakacha
Messages: 18
Registered: August 2009
Junior Member
Resolu ;;;;
l'utilisation de fonction strtotime()ยง Razz
public function getNbjc()
{
$total = strtotime($this->getDatefinc()) -strtotime( $this->getDatedebutc());

return $total/86400 ;
}
Re: subtracting days from 2 dates [message #85260 is a reply to message #85185 ] Mon, 14 September 2009 10:15 Go to previous messageGo to next message
benakacha  is currently offline benakacha
Messages: 18
Registered: August 2009
Junior Member

Solved,,,,
using strtotime () and effective.
public function getNbjc ()
(
$ total = strtotime ($ this-> getDatefinc ()), strtotime ($ this-> getDatedebutc ());

return $ total/86400;
)

this problem and solved (sustraction dates)
Now I want to calculate the salary of the employee
I module (employee and leave)
for the employee table I need to gross salary is entered by the administrator
and the table I need to state the number of days leave (getNbjc ()) that a local function and in PersoCongePeer
right now if I put the function to calculate salary in PersoEmployePeer
to return the result in
indexSuccess.php the module used

# class PersoEmployePeer extends BasePersoEmployePeer
(
public function getSalairePercent ()
(
$ total = $ this-> getSalaire () * (($ this-> getSalaire () / 30) * PersoCongePeer: getNbjc ());

return $ total;
#)



msg error :::::
500 | Internal Server Error | sfException
Call to undefined method BasePersoEmploye: getDatefinc



getdatefinc it is a field in the table leave (id, employee_id, typedeconge, datedebutc; datefinc)

in conclusion how can call a variable external module or work
pb join but I know how committed
Re: subtracting days from 2 dates [message #85272 is a reply to message #85260 ] Mon, 14 September 2009 13:00 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
shouldn't public function getSalairePercent() be in PersoEmploye instead of PersoEmployePeer ?

you cant acces to $this on a Peer class and also any fonction on Peer should be static.
Re: subtracting days from 2 dates [message #85274 is a reply to message #85272 ] Mon, 14 September 2009 13:06 Go to previous message
benakacha  is currently offline benakacha
Messages: 18
Registered: August 2009
Junior Member
thank you but I not understand their point Embarassed
Previous Topic:soustraction des date
Next Topic:how to serialize
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software