Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Inserting holiday fines Using php

Status
Not open for further replies.
Code:
 foreach ($period as $p )
 {
     $totalDays++;
     if($p->format( "w" )== 0 or $p->format( "w" )== 6 ) $weekendDays++;

//	 $tempDate = $p->format("Y-m-d");
//	 if(isset($tempArray[$tempDate])){ $holiday++; }

//icomment out mo muna yung 2 line sa taas
//ipalit mo to
echo $tempDate . ' - ';
echo (isset($tempArray[$tempDate']) ? 'meron' : 'wala';
echo '<br>';
 }

SEPTEMBER 24
Code:
Array
(
    [2017-09-22] => 
)
DatePeriod Object
(
    [start] => DateTime Object
        (
            [date] => 2017-09-15 00:00:00.000000
            [timezone_type] => 3
            [timezone] => Asia/Manila
        )

    [current] => 
    [end] => DateTime Object
        (
            [date] => 2017-09-24 00:00:00.000000
            [timezone_type] => 3
            [timezone] => Asia/Manila
        )

    [interval] => DateInterval Object
        (
            [y] => 0
            [m] => 0
            [d] => 1
            [h] => 0
            [i] => 0
            [s] => 0
            [weekday] => 0
            [weekday_behavior] => 0
            [first_last_day_of] => 0
            [invert] => 0
            [days] => 
            [special_type] => 0
            [special_amount] => 0
            [have_weekday_relative] => 0
            [have_special_relative] => 0
        )

    [recurrences] => 1
    [include_start_date] => 1
)


2017-09-15 - wala
2017-09-16 - wala
2017-09-17 - wala
2017-09-18 - wala
2017-09-19 - wala
2017-09-20 - wala
2017-09-21 - wala
2017-09-22 - meron
2017-09-23 - wala
Total days: 9

Weekend days: 3

Holidays: 0

₱ 30

SEPTEMBER 25

Code:
Array
(
    [2017-09-25] => 
    [2017-09-22] => 
)
DatePeriod Object
(
    [start] => DateTime Object
        (
            [date] => 2017-09-15 00:00:00.000000
            [timezone_type] => 3
            [timezone] => Asia/Manila
        )

    [current] => 
    [end] => DateTime Object
        (
            [date] => 2017-09-25 00:00:00.000000
            [timezone_type] => 3
            [timezone] => Asia/Manila
        )

    [interval] => DateInterval Object
        (
            [y] => 0
            [m] => 0
            [d] => 1
            [h] => 0
            [i] => 0
            [s] => 0
            [weekday] => 0
            [weekday_behavior] => 0
            [first_last_day_of] => 0
            [invert] => 0
            [days] => 
            [special_type] => 0
            [special_amount] => 0
            [have_weekday_relative] => 0
            [have_special_relative] => 0
        )

    [recurrences] => 1
    [include_start_date] => 1
)


2017-09-15 - wala
2017-09-16 - wala
2017-09-17 - wala
2017-09-18 - wala
2017-09-19 - wala
2017-09-20 - wala
2017-09-21 - wala
2017-09-22 - meron
2017-09-23 - wala
2017-09-24 - wala
Total days: 10

Weekend days: 4

Holidays: 0

₱ 30

SEPTEMBER 26
Code:
Array
(
    [2017-09-26] => 
    [2017-09-25] => 
    [2017-09-22] => 
)
DatePeriod Object
(
    [start] => DateTime Object
        (
            [date] => 2017-09-15 00:00:00.000000
            [timezone_type] => 3
            [timezone] => Asia/Manila
        )

    [current] => 
    [end] => DateTime Object
        (
            [date] => 2017-09-26 00:00:00.000000
            [timezone_type] => 3
            [timezone] => Asia/Manila
        )

    [interval] => DateInterval Object
        (
            [y] => 0
            [m] => 0
            [d] => 1
            [h] => 0
            [i] => 0
            [s] => 0
            [weekday] => 0
            [weekday_behavior] => 0
            [first_last_day_of] => 0
            [invert] => 0
            [days] => 
            [special_type] => 0
            [special_amount] => 0
            [have_weekday_relative] => 0
            [have_special_relative] => 0
        )

    [recurrences] => 1
    [include_start_date] => 1
)


2017-09-15 - wala
2017-09-16 - wala
2017-09-17 - wala
2017-09-18 - wala
2017-09-19 - wala
2017-09-20 - wala
2017-09-21 - wala
2017-09-22 - meron
2017-09-23 - wala
2017-09-24 - wala
2017-09-25 - meron
Total days: 11

Weekend days: 4

Holidays: 0

₱ 35

SEPTEMBER 27
Code:
Array
(
    [2017-09-26] => 
    [2017-09-25] => 
    [2017-09-22] => 
)
DatePeriod Object
(
    [start] => DateTime Object
        (
            [date] => 2017-09-15 00:00:00.000000
            [timezone_type] => 3
            [timezone] => Asia/Manila
        )

    [current] => 
    [end] => DateTime Object
        (
            [date] => 2017-09-27 00:00:00.000000
            [timezone_type] => 3
            [timezone] => Asia/Manila
        )

    [interval] => DateInterval Object
        (
            [y] => 0
            [m] => 0
            [d] => 1
            [h] => 0
            [i] => 0
            [s] => 0
            [weekday] => 0
            [weekday_behavior] => 0
            [first_last_day_of] => 0
            [invert] => 0
            [days] => 
            [special_type] => 0
            [special_amount] => 0
            [have_weekday_relative] => 0
            [have_special_relative] => 0
        )

    [recurrences] => 1
    [include_start_date] => 1
)


2017-09-15 - wala
2017-09-16 - wala
2017-09-17 - wala
2017-09-18 - wala
2017-09-19 - wala
2017-09-20 - wala
2017-09-21 - wala
2017-09-22 - meron
2017-09-23 - wala
2017-09-24 - wala
2017-09-25 - meron
2017-09-26 - meron
Total days: 12

Weekend days: 4

Holidays: 0

₱ 40
 
Last edited:
Nandito ang problema mo, pero hindi ka dito magpapalit. Explanation: new DatePeriod list all inclusive dates from the 1st parameter ($borrowdate) up to 3rd parameter ($returndate) excluding the last date.

Code:
$period = new DatePeriod($borrowdate, $interval, $returndate);

meaning, kung ang $borrowdate mo ay September 1 at ang $returndate mo ay September 5, ang iiinclude lang nya sa $period variable ay September 1, 2, 3, 4. Yun ang problema kung bakit hindi sumasama ang September 25, kahit na sabihing September 25 ang last date, and at the same time, holiday din.

para gumana yan:
Code:
//change this
$returndate->setTime(0,0);
//to this
$returndate->setTime(0,1);

What happened? nung nag-new DatePeriod ka, ang chini-check nya ay yung date difference of '2017-09-01 00:00:00' and '2017-09-05 00:00:00'. Sa unang tingin, 5 days pa din talaga ang date difference nyan, but then, based dun sa naunang explanation ko, it EXCLUDES the last date lalo na kung mag-equal yung comparison dun sa last iteration. So para saan yung $returndate->setTime(0,1); ? Parang dinaya na din natin yung server into thinking na yung last date na iko-compare ay '2017-09-05 00:01:00', making it not equal sa last condition, mapapasama na yung date na yun sa ire-return sa object na $period.

Please do the necessary changes
 
Nandito ang problema mo, pero hindi ka dito magpapalit. Explanation: new DatePeriod list all inclusive dates from the 1st parameter ($borrowdate) up to 3rd parameter ($returndate) excluding the last date.

Code:
$period = new DatePeriod($borrowdate, $interval, $returndate);

meaning, kung ang $borrowdate mo ay September 1 at ang $returndate mo ay September 5, ang iiinclude lang nya sa $period variable ay September 1, 2, 3, 4. Yun ang problema kung bakit hindi sumasama ang September 25, kahit na sabihing September 25 ang last date, and at the same time, holiday din.

para gumana yan:
Code:
//change this
$returndate->setTime(0,0);
//to this
$returndate->setTime(0,1);

What happened? nung nag-new DatePeriod ka, ang chini-check nya ay yung date difference of '2017-09-01 00:00:00' and '2017-09-05 00:00:00'. Sa unang tingin, 5 days pa din talaga ang date difference nyan, but then, based dun sa naunang explanation ko, it EXCLUDES the last date lalo na kung mag-equal yung comparison dun sa last iteration. So para saan yung $returndate->setTime(0,1); ? Parang dinaya na din natin yung server into thinking na yung last date na iko-compare ay '2017-09-05 00:01:00', making it not equal sa last condition, mapapasama na yung date na yun sa ire-return sa object na $period.

Please do the necessary changes

Galing mo sir bwisit napakagaling mo sir natapos mo problema ko maraming salamat sir!!! pagpalain ka po ng Diyos maraming maraming salamat po sir sana ituloy mo pa po pagtulong sa kapwa may kapalit na ibibigay po ang Diyos sayo maraming salamat po talaga uploading na kase ng website mamaya buti na lang po natapos mo Salamat po!!!
 
OT: galing talaga ni idol :D

congrats boss nasolve narin problema mo
 
yan ang may alam simple but rock...galing talaga ni sir jskhulitz,,,malinaw pa sa sikat ng araw yung explanation...solve na ang problemo...galing
 
Last edited:
OT: galing talaga ni idol :D

congrats boss nasolve narin problema mo

yan ang may alam simple but rock...galing talaga ni sir jskhulitz,,,malinaw pa sa sikat ng araw yung explanation...solve na ang problemo...galing

Galing talaga, di na nya hahayaan iwan lang yung problema talagang sinosolve niya thumbs up ako sa kanya :thumbsup:
 
Galing talaga, di na nya hahayaan iwan lang yung problema talagang sinosolve niya thumbs up ako sa kanya :thumbsup:

hahahaha...

magaling po talaga yan si master jskhulitz... d'best po yan
 
Status
Not open for further replies.
Back
Top Bottom