Forum Moderators: coopster
I was wondering if there is anything special that i should do to keep the values stored for later reference other than using session variables?
The problem is that sometimes a customer can come, and pay the installments on two parts on different days... how can i set the database structure so that i can compare the multiple inputs with the primary actual input so that i can calculate the delays?
when I go to another page, the value isn't stored on the server...
Invoice no|Invoice Date |Invoice Value |Payment Value|Payment Date |
1 | 2010/05/13 | 5000$ | 2500$ | 2010/05/13 |
1 | 2010/05/13 | 5000$ | 2500$ | 2010/06/01 |
2 | 2010/06/13 | 5000$ | - | - |
3 | 2010/07/13 | 5000$ | - | - |
4 | 2010/08/13 | 5000$ | - | - |
DO NOT use cookies for this sort of stuff, because all the information is stored on the users computer and very easy to manipulate.
Invoice_Date [YYYY-MM-DD] format,
Payment_Date [YYYY_MM_DD] format.
delay = payment_date - invoice_date
you are late 1 month and 26 days
with a total delay of 56 days which is equal to 1.8 Months
DATEDIFFfunction, but i have many dates stored on my database, and based on these dates, i need to do many different calculations (ex. adding, and subtracting for different cases). If i used this method, then i would be overloading the server through the many sql queries, so i would have preferred to store the dates on different variables, and then use these variables to do any type of calculations that i wanted.
mktimefunction, and the
strotimebut i do not seem to understand and grasp the concept to efficiently utilize it to do all of the calculations to relief the server from many of the MySQL queries.
format of [YYYY-MM-DD]
1- Finding the Difference between 2 dates.
$date1 = '2010-12-03';
$date2 = '2010-11-04';
$pieces = explode("-", $date1);
$date1 = mktime(0, 0, 0, $pieces[1], $pieces[0], $pieces[2]);
$pieces = explode("-", $date2);
$date2 = mktime(0, 0, 0, $pieces[1], $pieces[0], $pieces[2]);
$difference_in_seconds = abs($date1 - $date2); $date1 = '2010-12-03';
$date2 = '2010-11-04';
$pieces = explode("-", $date1);
$date1 = mktime(0, 0, 0, $pieces[1], $pieces[0], $pieces[2]);
$pieces[0]= year
$pieces[1]= month
$pieces[2]= days
mktime(hour,minute,second,month,day,year,is_dst)
$date1 = mktime(0, 0, 0, $pieces[1], $pieces[2], $pieces[0]);
$date1 = mktime(0, 0, 0, $pieces[1], $pieces[0], $pieces[2]);
2- Adding a specific period (ex 1 month) to a stored date to calculate the expiry date.
and so on...
2months x 30 days x 24 hours x 60 mins x 60 secs = Total Number of seconds
$initialdate= '2010-12-03';
$pieces = explode("-", $date1);
$initialdate = mktime(0, 0, 0, $pieces[1], $pieces[0], $pieces[2]);
$expire= 2*30*24*60*60;
$finaldate= $initialdate+$expire; <!-- having the result being calculated in seconds -->
$result= date("Y/m/d", $finaldate);
$daysdelay= 20;
$expire=mktime(0,0,0,date("m"),date("d")+$daysdelay,date("Y"));
$thirty_days_from_now = strtotime('+30 days');
$daysdelay=20;
$expire=mktime(0,0,0,date("m"),date("d")+,date("Y"));$daysdelay
$date1 = '2010-12-03';
$pieces = explode("-", $date1);
$daysdelay=20;
$datelate = mktime(0, 0, 0, $pieces[1], $pieces[2]+$daysdelay, $pieces[0]);
$datelate = mktime(0, 0, 0, $pieces[1], $pieces[2]+$daysdelay, $pieces[0]);
$date="2010-12-20"
$daysdelay="20"; //days
$pieces = explode("-", $date);
$datelate = mktime(0, 0, 0, $pieces[1], $pieces[2]+$daysdelay, $pieces[0]);
$datefinal= date("d-m-Y",$datelate);
echo $datefinal; // will this be the output 09-01-2011
$future_date = date('m-d-Y', strtotime('+30 days'));
$pieces = explode("-", $future_date);
$future_date = mktime(0, 0, 0, $pieces[0], $pieces[1], $pieces[2]);
$future_date = strtotime('+30 days');
$date2 = date('Y-m-d', strtotime('+1 week 5 hours 7 minutes 23 seconds'));
int strtotime ( string $time [, int $now ] )
$date2 = date('Y-m-d', strtotime('+1 week 5 hours 7 minutes 23 seconds'));
$date2 = date('Y-m-d', strtotime('+1 week 5 hours 7 minutes 23 seconds'));
$startDate = strtotime("1985");//Reto Clock of sorts :)
echo date("Y-m-d", strtotime("+1 month", $startDate));
1985-08-12
Saying plus 20 days in mktime will fail - as mktime does not understand the 51st of (month)
$date="2010-12-20"
$daysdelay="20"; //days
$pieces = explode("-", $date);
$datelate = mktime(0, 0, 0, $pieces[1], $pieces[2]+$daysdelay, $pieces[0]);
$datefinal= date("d-m-Y",$datelate);