Postingan lainnya
Bagaimana script/query mengurangi jumlah hak_cuti
Assalamualaikum selamat pagi mohon bantuannya bagaimana script/query mengurangi jumlah hak_cuti di tabel pegawai ketika di tabel mohon cuti field jml_hari itu disetujui? jadi ini pake 2 tabel ?
1 Jawaban:
rumusnya : sisa cuti - jumlah hari cuti
<a href='https://stackoverflow.com/questions/3653882/how-to-count-days-between-two-dates-in-php'>hitung hari</a> <pre> <?php
$sisaCuti = 10;
$cutiDari = strtotime("2020/01/13"); $cutiSampai = strtotime("2020/01/16");
$timeDiff = abs($cutiSampai - $cutiDari );
$numberDays = $timeDiff / 86400; // 86400 seconds in one day
// and you might want to convert to integer $numberDays = intval($numberDays);
$hasil = $sisaCuti - $numberDays;
// query sql update pegawai set cuti = $hasil where id_pegawai = ? </pre>