Results 1 to 8 of 8

Thread: mohon pertolongan..coding function nak bina kalendar n nk kira hari dalam calendar

  1. #1
    Join Date
    May 2007
    Location
    perak
    Posts
    4
    Rep Power
    0

    mohon pertolongan..coding function nak bina kalendar n nk kira hari dalam calendar

    salam ...
    aku nak buat satu kiraan tarikh untuk piagam pelanggan kat company aku..
    piagam pelanggan ni cuma kira tarikh hari bekerja sahaja...cthye hari sabtu ahad x perlu dikira...masalhye..aku x tau macamana nak buat functioni:

    1) disable kan tarikh2 tidak bekerja dalam kalendar
    2) nak kira bil hari utuk tarikh yg bekerja shj..

    sesape boleh tolong aku...plzzz...

    aku tensen nih...

    sesape rs bminta nk tolong aku doakan tuk korg dipermudahkn segala urusan harian..

  2. #2
    Join Date
    Jun 2001
    Location
    Mystic Kingdoms
    Posts
    2,749
    Rep Power
    272
    Cuba bagitau saya, macammana orang nak tolong anda?

    Kod pun tak disertakan. Setakat mana coding anda.
    Tiada beritahu apa yang telah anda buat.
    Apa sistem anda, dan lain2.

    Anda tidak nampak serius dalam memohon pertolongan lansung!.

    NOTA: Jangan buat orang yang nak menolong anda bertanya 5,6 kali untuk faham soalan anda!

  3. #3
    Join Date
    May 2007
    Location
    perak
    Posts
    4
    Rep Power
    0

    sy newbie of php

    sy ni br nak menjinak2 kn dr dalam php ni..sy budak praktikal kat majlis perbandaran..supervisor sy soh buat sistem website gne php.....pasal piagam pelanggan...kalo design saye boleh buat..tp nak masukkan sesuatu function jd masalah..sbb sy xtau...
    boleh x sesape tolong cmne nk permudahkan dpt coding nk kira bilangan hari dalam kalendar...ape website yg ade sediakan complete open source calendar coding..??
    da byk cube..tp mengarut jdnyer...

    apa yg sy perlu buat ialah:
    1) cari bilangan hari dalam kalendar per month
    2) disable kn hari tidak bekerja..contoh sabtu ahad..

    maaf kalo nyusahkan..saye org baru dlm php

  4. #4
    Join Date
    Aug 2006
    Location
    Malaysia
    Posts
    1,576
    Rep Power
    185

    Practical Date/Time examples with PHP and MySQL

    Have a try - using PHP math operators and MySQL functions.

    Practical Date/Time examples with PHP and MySQL - The UNIX timestamp
    http://www.devarticles.com/c/a/MySQL...PHP-and-MySQL/

    http://www.devarticles.com/c/a/MySQL...P-and-MySQL/1/
    PHP Code:
    <?php
    // The parameters of this function are the dates to be compared.
    // The first should be prior to the second. The dates are in
    // the form of: 1978-04-26 02:00:00.
    // They also can come from a web form using the global $_POST['start']
    // and $_POST['end'] variables.
    function date_diff($str_start$str_end)
    {

    $str_start strtotime($str_start); // The start date becomes a timestamp
    $str_end strtotime($str_end); // The end date becomes a timestamp

    $nseconds $str_end $str_start// Number of seconds between the two dates
    $ndays round($nseconds 86400); // One day has 86400 seconds
    $nseconds $nseconds 86400// The remainder from the operation
    $nhours round($nseconds 3600); // One hour has 3600 seconds
    $nseconds $nseconds 3600;
    $nminutes round($nseconds 60); // One minute has 60 seconds, duh!
    $nseconds $nseconds 60;

    echo 
    $ndays." days, ".$nhours." hours, ".$nminutes." minutes, ".$nseconds."
    echo “seconds<br>\n"
    ;

    }

    // Test the function with several values
    date_diff("1978-04-26""2003-01-01");
    date_diff("1984-10-24 15:32:25""2003-01-01");
    date_diff("2001-10-28 17:32:25""2003-01-01 12:00:18");
    ?>
    Practical Date/Time examples with PHP and MySQL - The UNIX timestamp
    http://www.devarticles.com/c/a/MySQL...P-and-MySQL/2/
    PHP Code:
    // Calculating my exact age
    $str_birthday "1978-04-26"// My Birth Day
    $str_today date("Y-m-d H:i:s"); // The exact time
    date_diff($str_birthday$str_today);

    ?> 
    As you see I’m using the same function but changing the parameters a little. First $str_birthday is a fixed string, in this example my birthday.

    You can, for example, ask the user through a form and then call the function like this:

    <?php date_diff($_POST[‘birthday’], date("Y-m-d H:i:s")); ?>

    The trick here is the date() function. With its given parameters prints the exact date of today in the format YYYY-MM-DD hh:mm:ss.

    The code returns:
    9024 days, 17 hours, 29 minutes, 57 seconds
    Practical Date/Time examples with PHP and MySQL - Dates with MySQL
    http://www.devarticles.com/c/a/MySQL...P-and-MySQL/3/
    mysql> SELECT UNIX_TIMESTAMP('1978-04-26 02:12:59');
    +---------------------------------------+
    | UNIX_TIMESTAMP('1978-04-26 02:12:59') |
    +---------------------------------------+
    | 262422779 |
    +---------------------------------------+

    mysql> SELECT UNIX_TIMESTAMP('1978-04-26');
    +------------------------------+
    | UNIX_TIMESTAMP('1978-04-26') |
    +------------------------------+
    | 262414800 |
    +------------------------------+

    This will print the timestamp of the given date.

    Be careful when creating the structure and definitions for this kind of table. MySQL returns the UNIX timestamp as an unsigned integer, so keep this in mind when creating your database.

    Now, imagine you have a database with a column that contains a UNIX timestamp, you can also convert it to a ‘human-readable’ date using MySQL like this:
    mysql> SELECT FROM_UNIXTIME('262422779');
    +----------------------------+
    | FROM_UNIXTIME('262422779') |
    +----------------------------+
    | 1978-04-26 02:12:59 |
    +----------------------------+
    Practical Date/Time examples with PHP and MySQL - Date Addition and Subtraction
    http://www.devarticles.com/c/a/MySQL...P-and-MySQL/4/
    mysql> SELECT DATE_ADD('2004-02-28 23:50:00', INTERVAL 10 MINUTE); #2004 is a leap year
    +-----------------------------------------------------+
    | DATE_ADD('2004-02-28 23:50:00', INTERVAL 10 MINUTE) |
    +-----------------------------------------------------+
    | 2004-02-29 00:00:00 |
    +-----------------------------------------------------+

    Subtraction is done with the DATE_SUB() function in the same way:

    mysql> SELECT DATE_SUB('2004-03-01', INTERVAL 1 DAY);
    +----------------------------------------+
    | DATE_SUB('2004-03-01', INTERVAL 1 DAY) |
    +----------------------------------------+
    | 2004-02-29 |
    +----------------------------------------+

    And don’t worry about December 31st and January 1st transition:

    mysql> SELECT DATE_SUB('2004-01-01', INTERVAL 1 DAY);
    +----------------------------------------+
    | DATE_SUB('2004-01-01', INTERVAL 1 DAY) |
    +----------------------------------------+
    | 2003-12-31 |
    +----------------------------------------+
    Practical Date/Time examples with PHP and MySQL - Conclusion
    http://www.devarticles.com/c/a/MySQL...P-and-MySQL/5/

  5. #5
    Join Date
    Aug 2006
    Location
    Malaysia
    Posts
    1,576
    Rep Power
    185

  6. #6
    Join Date
    Sep 2005
    Location
    in my body lar...
    Posts
    1,325
    Rep Power
    0
    Quote Originally Posted by nemia84 View Post
    maaf kalo nyusahkan..saye org baru dlm php
    kami di forum ini memang suka tolong menolong... tapi u sikit susahkan orang sebab banyak member di sini tak erti bahasa shortcut BM..... example what is tp? what is jdnyer? what is gne? what is rs??????

    kalaulah u nak orang tolong u... first first tolonglah mereka memahami apa yang u type dulu lar....

    ok balik ke soalan u... logic dia start macam di bawah... tapi coding tu kenalah u buat sendiri... kalau u nak aku code semua... gaji u kena kasi sama i dulu ya...

    Step 1:
    Know which month you are in. by using date("n") function
    $currentmonth = date("n");

    Step 2:
    If month on 1/3/5/7/8/10/12 follow on step 3
    If month on 2 follow on step 4
    If month on 4/6/9/11 follow on step 5

    Step 3:
    loop through all the day from 1 to 31 of the month and evaluate each day to determine the not working day.

    <?php
    $m = date("n");
    $y = date("Y");
    $i=1;

    $maxday=31;

    $notworking = 0;

    while($i<=$maxday)
    {
    $d= date("D", mktime(0,0,0,$m,$i,$y));
    if ($d=="Sun")
    $notworking = $notworking + 1;
    elseif ($d=="Sat")
    $notworking = $notworking + 1;
    }
    $i++;
    }
    echo ("Total not working day this month are: ".$notworking);
    ?>
    Step 4:
    check for leap year that feb have 29 days,
    if leap year loop from day 1 to 29 else from 1 to 28 and evaluate each day to determine the not working day.

    <?php
    $m = date("n");
    $y = date("Y");
    $i=1;

    if (date("L")==1)
    $maxday=29;
    else
    $maxday=28;

    $notworking = 0;

    while($i<=$maxday)
    {
    date("D", mktime(0,0,0,$m,$i,$y));
    if ($d=="Sun")
    $notworking = $notworking + 1;
    elseif ($d=="Sat")
    $notworking = $notworking + 1;
    }
    $i++;
    }
    echo ("Total not working day this month are: ".$notworking);
    ?>

    Step 5:
    loop through all the day from 1 to 30 of the month and evaluate each day to determine the not working day.

    <?php
    $m = date("n");
    $y = date("Y");
    $i=1;
    $maxday=31;

    $notworking = 0;

    while($i<=$maxday)
    {
    $d= date("D", mktime(0,0,0,$m,$i,$y));
    if ($d=="Sun")
    $notworking = $notworking + 1;
    elseif ($d=="Sat")
    $notworking = $notworking + 1;
    }
    $i++;
    }
    echo ("Total not working day this month are: ".$notworking);
    ?>

    for complete php date coding... .please refer to PHP Date / Time Functions
    Last edited by iamfreelancer; 10-05-2007 at 09:56 AM.

  7. #7
    Join Date
    Jan 2007
    Location
    Petaling Jaya
    Posts
    867
    Rep Power
    167
    seriously, is not tat i m lazy to read or wat, but i really found myself in the middle of the mist when i read those language. Once i read the middle part, i can't relate wat's written on the top part, once i read the last part i can't recall wat is said in the middle part, when i wanted to read the first part again, again the last part was already forgotten wat is said...

    all the time was taken to figure out wat's he trying to say

    piagam???
    masalhye??
    tensen?? (tension?)
    bminta??

  8. #8
    Join Date
    Sep 2005
    Location
    in my body lar...
    Posts
    1,325
    Rep Power
    0
    actually i also have hard time understanding wat they want.... most of the time i just read their thread title and that give much better understanding than their thread body....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. camne nak kira data guna php
    By putrisakura in forum Website Programming
    Replies: 16
    Last Post: 16-02-2009, 09:59 AM
  2. Wordpress Plugin Function Call, need some coding help
    By calvynlee in forum Website Programming
    Replies: 0
    Last Post: 11-02-2009, 06:49 PM
  3. mohon pertolongan..camne function nak bagi tambah event ni?
    By nemia84 in forum Website Programming
    Replies: 2
    Last Post: 19-07-2007, 06:40 PM
  4. Mohon Sumbangan Kos Surgeri Nuur Qistina Hayani
    By nazrol in forum Mamak Stall
    Replies: 0
    Last Post: 11-05-2007, 09:56 PM
  5. camna nak buat kalendar...
    By pikachu78 in forum Website Programming
    Replies: 1
    Last Post: 24-04-2002, 05:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37