How can i check the days between 2 dates?
#1

i fixed it, thanks anyway.
Reply
#2

pawn Code:
stock CalcDate(&year, &month, &day, extradays)
{
    getdate(year, month, day);
    day += extradays;
    // suppose day = 27 and extradays = 8
    // day is now 35

    switch(month)
    {
        case 1, 3, 5, 7, 8, 10, 12: // 31 day months
        {
            if(day > 31 )
            {
                if(month == 12)
                {
                    month = 1;
                    year++;
                }
                else
                {
                    month++;
                }
                day -= 31; // day is now 4
            }
        }
        case 4, 6, 9, 11: // 30 day months
        {
            if(day > 30 )
            {
                month++;
                day -= 30;
            }
        }
        case 2: // february
        {
            if((day + extradays) > 28 )
            {
                month++;
                day -= 28;
            }
        }
    }
}
Reply
#3

no man... i need to write 2 date, and it's return me the days between them, no the days from now.

edit -

i did it alone thanks anyway
Reply
#4

So why not post how you did it and help people?
Reply
#5

PHP Code:
stock DatesTime(Start[], End[],&offest)
{
    new 
dtmp[256], idx1idx2;
    
dtmp strtok(Startidx1'.');
    new 
StartDay strval(dtmp);
    
dtmp strtok(Startidx1'.');
    new 
StartMonth strval(dtmp);
    
dtmp strtok(Startidx1'.');
    new 
StartYear strval(dtmp);
    
dtmp strtok(Endidx2'.');
    new 
EndDay strval(dtmp);
    
dtmp strtok(Endidx2'.');
    new 
EndMonth strval(dtmp);
    
dtmp strtok(Endidx2'.');
    new 
EndYear strval(dtmp);
    new 
init_date mktime(12,0,0,StartDay,StartMonth,StartYear);
    new 
dest_date mktime(12,0,0,EndDay,EndMonth,EndYear);
    
offest dest_date init_date;
    
offest floatround(offest/60/60/24floatround_floor);
    return 
1;

enjoy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)