| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /wamp/www/simbada_2019/assets/js/ |
Upload File : |
function bulan(start, end, period = "month")
{
day = 0;
month = 0;
month_array = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
datestart = Date.parse(start) / 1000;
dateend = Date.parse(end) / 1000;
month_start = start.substring(5, 7);
current_year = start.substring(0, 4);
diff = dateend - datestart;
date = diff / (60 * 60 * 24);
day = date;
awal = 1;
while(date > 0)
{
if(awal)
{
loop = month_start - 1;
awal = 0;
}
else
{
loop = 0;
}
for (i = loop; i < 12; i++)
{
if(current_year % 4 == 0 && i == 1)
day_of_month = 29;
else
day_of_month = month_array[i];
date -= day_of_month;
if(date <= 0)
{
if(date == 0)
month++;
break;
}
month++;
}
current_year++;
}
switch(period)
{
case "day" : return day; break;
case "month" : return month; break;
case "year" : return int(month / 12); break;
}
}