i'm havig problem with my program..date comptation part =(

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
jesar_gacula
Forum Newbie
Posts: 2
Joined: Wed Oct 22, 2008 1:40 pm

i'm havig problem with my program..date comptation part =(

Post by jesar_gacula »

I have this program that compute due dates, wherein a given date will be added by a number of days.

Ex.
Given Date: 2008-10-23
Days to be added: 5 days
Due Date: 2008-10-28

It worked perfectly on my localhost and on out testing server at the office. But when I implemented it on our branches, the program doesn't compute for due date.

My code:

Code: Select all

 
$dDueDate = date("Y-m-d", strtotime("+".$oResTrdRec->fields['DAYS']." days", strtotime($oResTrdRec->fields['INVOICEDATE'])));
if (strtotime($dDueDate) <= strtotime($oResTrdRec->fields['INVOICEDATE'])) // if the above procedure fails, try the next
{
    $dInvYear   = intval(substr($oResTrdRec->fields['INVOICEDATE'],0,4)); // my efin codes (Jesar James Alas Gacula)
    $dInvMonth  = intval(substr($oResTrdRec->fields['INVOICEDATE'],5,2));
    $dInvDay    = intval(substr($oResTrdRec->fields['INVOICEDATE'],8,2));
    $dDue       = intval($oResTrdRec->fields['DAYS']);
    $dNewDate   = mktime(0,0,0,$dInvMonth,$dInvDay+$dDue,$dInvYear);
    $dDueDate   = date("Y-m-d", $dNewDate);
    if (strtotime($dDueDate) <= strtotime($oResTrdRec->fields['INVOICEDATE'])) // if the above procedure fails again, try the last computation of date.
    {
        $dDueDate = fnc_date_calc($oResTrdRec->fields['INVOICEDATE'],$oResTrdRec->fields['DAYS']); // Sir JB's codes
    }
    else // if still fails..
    {
        $dDueDate = '0000-00-00';
    }
}
 
$oStrAplHdr  = $oResTrdRec->fields['TAON']."|".$oResTrdRec->fields['BUWAN']."|".$oResTrdRec->fields['INVOICENO']."|";
$oStrAplHdr .= $oResTrdRec->fields['INVOICEDATE']."|".$oResTrdRec->fields['VENDORCODE']."|".[b]$dDueDate[/b]."|";
$oStrAplHdr .= $oResTrdRec->fields['BRANCHCODE']."|".$oResTrdRec->fields['TOTAMT']."|".$oResTrdRec->fields['EWT']."|";
$oStrAplHdr .= $oResTrdRec->fields['REFERENCENO']."|".$oResTrdRec->fields['DEPTCODE']."|".$oResTrdRec->fields['DOCTYPEID']."|";
$oStrAplHdr .= $oResTrdRec->fields['TRANSTYPEID']."|".$oResTrdRec->fields['PARTICULARS']."|".'Available'."|";
$oStrAplHdr .= 'Y'."|".$tDateTime."|".$oResTrdRec->fields['ADDEDBY']."|";
$oStrAplHdr .= $oResTrdRec->fields['TOTAMT']."|".$oResTrdRec->fields['EWT']."|".$tDateTime."|";
$oStrAplHdr .= $oResTrdRec->fields['ADDEDBY']."|".$oResSelCom->fields['COMPANYCODE'];
 
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: i'm havig problem with my program..date comptation part =(

Post by andyhoneycutt »

Could you post some error messages or expected behavior of your code snippet?

-Andy
jesar_gacula
Forum Newbie
Posts: 2
Joined: Wed Oct 22, 2008 1:40 pm

Re: i'm havig problem with my program..date comptation part =(

Post by jesar_gacula »

it doesn't return any error message. what i cannot understand is that, it works perfectly on other branches, while it doesn't compute due date on others.
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: i'm havig problem with my program..date comptation part =(

Post by andyhoneycutt »

Are your other branches running the same version of PHP as your development server?

-Andy
Post Reply