Berekening...

Gestart doorDylan8 reacties47 weergaven

9 berichten · pagina 1 van 1

Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Hoi,

Ik wil een script maken dat ik kan zien over hoeveel dagen het de 11de is. Hierbij wil ik ook een proces bar maken met procenten. Maar ik ben zelf niet echt goed in rekenen. Dus..

Ik wou weten, hoe kan je bereken hoeveel dagen het is maar dan in procenten? Dus stel:

Het is 11-2-2013 dan moet de proces bar op 100% staan en wanneer het de 12-2-2013 is weer op 0% etc.

Hopelijk snappen jullie het.

toevoeging op 14 januari 2013, 16:01:59:
Beter voorbeeld:

Als een maand 30 dagen duurd en het is nu de 15e dan is het aantal procenten dus 50%, op de 30ste 100% en op de 1e 0% hoe kan ik de andere dagen bereken? Ook wanneer de maand 29 dagen heeft etc.
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$days[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"t"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$daysLeft[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$days[/COLOR][COLOR= #007700]-([/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"j"[/COLOR][COLOR= #007700])-[/COLOR][COLOR= #0000BB]11[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"j"[/COLOR][COLOR= #007700]) <[/COLOR] [COLOR= #0000BB]11[/COLOR][COLOR= #007700]){[/COLOR]
    [COLOR= #0000BB]$days[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"t"[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/strtotime"]strtotime[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y"[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]"-"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"n"[/COLOR][COLOR= #007700])-[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]"-01 00:00:00"[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$daysleft[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]11[/COLOR][COLOR= #007700]-[/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"j"[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$daysLeft[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$days[/COLOR][COLOR= #007700])[/COLOR] [COLOR= #0000BB]$daysLeft[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$daysPast[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$days[/COLOR][COLOR= #007700]-[/COLOR][COLOR= #0000BB]$daysLeft[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$percentage[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700](([/COLOR][COLOR= #0000BB]$daysPast[/COLOR]/[COLOR= #0000BB]$days[/COLOR][COLOR= #007700])*[/COLOR][COLOR= #0000BB]100[/COLOR][COLOR= #007700]);[/COLOR]
?>


Astu
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Thanks.

toevoeging op 14 januari 2013, 16:20:20:
Hoe kan ik laten zien over hoeveel dagen het de 11e is?

toevoeging op 14 januari 2013, 16:53:26:
Laatmaar.
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Bump,

ik zoek een andere code. deze werkt niet en blijft altijd op 0% staat;
http://hoelangnog.eu5.org/
0
Janm

Lid

Berichten
6.170
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Je weet al wel hoeveel procent het is? Dan doe je een width van 80% als de hij 80% is. E.d.
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Janm schreef:
Je weet al wel hoeveel procent het is? Dan doe je een width van 80% als de hij 80% is. E.d.
Nee, ik wil dat een script uitrekend hoeveel % het is.

toevoeging op 17 januari 2013, 17:30:46:
Bump.
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Bump.
0
Berichten
443
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
deel / geheel * 100?

bijv:

als de maand 30 dagen heeft, en tis nu dag 10:
10 / 30 * 100 = 33,3%

moet je natuurlijk wel iets zoeken om aantal dagen in de huidige maand te vinden wink
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Maar ik wil dat het de 11de 100% is. Dus dan is het 10/11 toch?
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren