PDA

View Full Version : Php date calculation



funkyfela
08 Apr 2010, 12:48 PM
Hello all.
how do i calculate the difference between dates. i.e if i make a transaction on 12/10/2007 and it is stored in my db. and the transaction was processed on 15/10/2007. is there a way i could write a code to calculate the difference with php? hope am making sense here!

thanks

Alan
08 Apr 2010, 04:14 PM
If you convert the dates to unix timestamps, they are then converted to the number of seconds that have passed since 01/01/1970. As they are in a nice linear fashion, simple subtraction does the trick.

The function you will need is: strtotime (http://www.php.net/manual/en/function.strtotime.php)