Jump to content

lanu

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lanu's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I got it to work, though not the most elegant solution, it does the job for my purposes. I have given each of the days different values in the case that its a date earlier than 11.11.11 so the days and cycles match up forwards and backwards. Thanks again for all your help I LOOOOVE PHP FREAKS! <?php // THEE AURON CALCULATOR $elvenportal = mktime(11,11,11,11,11,2011); $now = mktime(date("H"),date("i"),date("s"),date("n"),date("j"),date("Y")); $late = date("H"); $theeday = date("d")-1; if ($late < 7) {$now = mktime(11,11,11,date("n"),$theeday,date("Y"));}; if ($_POST["dayz"] != "" ){ if ($_POST["month"] != "" ){ if ($_POST["year"] != "" ){ $now = mktime(11,11,11,$_POST["month"],$_POST["dayz"],$_POST["year"]); };};}; $offset = $now - $elvenportal; $beyondportal = abs($offset/(60*60*24)); $beyondportal = abs($beyondportal+108); $day = abs($beyondportal % 26 + 1); //26 days in the cycle. +1 to make it 1-26 rather than 0-25 $cycle = abs(intval($beyondportal / 26) % 14+1); //26 days in your cycles. +1 to make it 1-14 rather than 0-13 if ($elvenportal > $now){ if ($day == 6){$day = 4;} else if ($day == 7){$day = 3;} else if ($day == {$day = 2;} else if ($day == 9){$day = 1;} else if ($day == 10){$day = 26;} else if ($day == 11){$day = 25;} else if ($day == 12){$day = 24;} else if ($day == 13){$day = 23;} else if ($day == 14){$day = 22;} else if ($day == 15){$day = 21;} else if ($day == 16){$day = 20;} else if ($day == 17){$day = 19;} else if ($day == 18){$day = 18;} else if ($day == 19){$day = 17;} else if ($day == 20){$day = 16;} else if ($day == 21){$day = 15;} else if ($day == 22){$day = 14;} else if ($day == 23){$day = 13;} else if ($day == 24){$day = 12;} else if ($day == 25){$day = 11;} else if ($day == 26){$day = 10;} else if ($day == 1){$day = 9;} else if ($day == 2){$day = 8;} else if ($day == 3){$day = 7;} else if ($day == 4){$day = 6;} else if ($day == 5){$day = 5;} else if ($day == 6){$day = 4;}; if ($beyondportal > 4){ if ($cycle == 1){$cycle = 8;} else if ($cycle == 2){$cycle = 7;} else if ($cycle == 3){$cycle = 6;} else if ($cycle == 4){$cycle = 5;} else if ($cycle == 5){$cycle = 4;} else if ($cycle == 6){$cycle = 3;} else if ($cycle == 7){$cycle = 2;} else if ($cycle == {$cycle = 1;} else if ($cycle == 9){$cycle = 14;} else if ($cycle == 10){$cycle = 13;} else if ($cycle == 11){$cycle = 12;} else if ($cycle == 12){$cycle = 11;} else if ($cycle == 13){$cycle = 10;} else if ($cycle == 14){$cycle = 9;}; }; /* if ($day == 1){$day = 5;} else if ($day == 2){$day = 4;} else if ($day == 3){$day = 3;} else if ($day == 4){$day = 2;} else if ($day == 5){$day = 1;} else if ($day == 6){$day = 26;} else if ($day == 7){$day = 25;} else if ($day == {$day = 24;} else if ($day == 9){$day = 23;} else if ($day == 10){$day = 22;} else if ($day == 11){$day = 21;} else if ($day == 12){$day = 20;} else if ($day == 13){$day = 19;} else if ($day == 14){$day = 18;} else if $day == 15){$day = 17;} else if ($day == 16){$day = 16;} else if ($day == 17){$day = 15;} else if ($day == 18){$day = 14;} else if ($day == 19){$day = 13;} else if ($day == 20){$day = 12;} else if ($day == 21){$day = 11;} else if ($day == 22){$day = 10;} else if ($day == 23){$day = 9;} else if ($day == 24){$day = 8;} else if ($day == 25){$day = 7;} else if ($day == 26){$day = 6;} else{echo "";} if ($cycle = 5){$cycle = 1;} else if ($cycle = 6){$cycle = 14;} else if ($cycle = 7){$cycle = 13;} else if ($cycle = {$cycle = 12;} else if ($cycle = 9){$cycle = 11;} else if ($cycle = 10){$cycle = 10;} else if $cycle = 11){$cycle = 9;} else if ($cycle = 12){$cycle = 8;} else if ($cycle = 13){$cycle = 7;} else if ($cycle = 14){$cycle = 6;} else if ($cycle = 1){$cycle = 5;} else if ($cycle = 2){$cycle = 4;} else if ($cycle = 3){$cycle = 3;} else if ($cycle = 4){$cycle = 2;} else{echo "";}*/ }; ?>
  2. almost got it now. it works great going forward but backward has some issues. if beyond portal is a date from the past we run into a problem because 1 day BEFORE 0 is actually DAY 26 where as 1 day after is DAY 2. My problem is I'm getting DAY 2 when it is supposed to be getting DAY 26 and likewise any dates before 11.11.11 are being counted wrong. any suggestions? here's the code: $elvenportal = mktime(11,11,11,11,11,2011); $now = mktime(date("H"),date("i"),date("s"),date("n"),date("j"),date("Y")); $offset = $now - $elvenportal; $beyondportal = abs($offset/(60*60*24)); $beyondportal = $beyondportal+108; // start of new year is 108 days before 11.11.11 $day = $beyondportal % 26 + 1; //26 days in the cycle. +1 to make it 1-26 rather than 0-25 $cycle = intval($beyondportal / 26) % 14+1; //26 days in your cycles. +1 to make it 1-14 rather than 0-13 // do I need a conditional statement to calculate differently for negative numbers? ANy help would be greatly appreciated. thanks so much!
  3. This almost works for me but I'm really unsure about the math part: <?php $zeropoint = mktime(11, 11, 11, 06, 29, 2011); // zero date has been moved 135 days earlier to june 29th,2011 - cycle 1, day 1 - the new year of the calendar to simplify this $now = mktime(11,11,11,date("m"),date("d"),date("y")); // gets todays date $diff = $now - $zeropoint; // do i need to do another condition incase $now is less than zeropoint or will this work? $cycle = $diff % 364 ; // no idea what the math is supposed to be to determine which of the 14 cycles we are currently in based on the difference between $zeropiont and $now $day = $diff % 26 ; // no idea what the math is supposed to be to determine which of the 26 days we are currently in based on the difference between $zeropiont and $now echo 'Cycle '.$cycle.' '; echo 'Day: '.$day.' '; ?> Thank you all so much for your help it is greatly appreciated and encouraging!
  4. sorry about that here's the code I'm creating an alternative calendar system(non-gregorian) and so I need to know some basic math to figure some of this out and how to express it in php. the calendar year is 364 days long and it is split into 14 months that are 26 days long each. I have create a script that determines which day of 26 no problem, but getting the month is proving difficult. My code I'm using to display the content for each of the 26 days is as follows: <?php if ($beyondportal % 26 == $day1 || abs($beyondportal) % 26 == $day1){ ?> It's day 1 <?php } ; ?> <?php if ($beyondportal % 26 == $day2 || abs($beyondportal) % 26 == $day2){ ?> It's day 2 <?php } ; ?> etc... up to 26 here is the code that gives $beyondportal and the day variables their values <?php // gets todays date and compares it to 11.11.11, if its positive days get a certain set of values, if negative they get another $elvenportal = mktime(11,11,11,11,11,2011); $now = mktime(11,11,11,date("m"),date("d"),date("y")); $late = date("H"); if ($late < 5) {$now = mktime(11,11,11,date("m"),date("d")-1,date("y"));}; if ($_POST["dayz"] != "" ){ if ($_POST["month"] != "" ){ if ($_POST["year"] != "" ){ $now = mktime(11,11,11,$_POST["month"],$_POST["dayz"],$_POST["year"]); };};}; $day1 = 22;$day2 = 23;$day3 = 24;$day4 = 25;$day5 = 0;$day6 = 1;$day7 = 2;$day8 = 3;$day9 = 4;$day10 = 5;$day11 = 6;$day12 = 7;$day13 = 8;$day14 = 9;$day15 = 10;$day16 = 11;$day17 = 12;$day18 = 13;$day19 = 14;$day20 = 15;$day21 = 16;$day22 = 17;$day23 = 18;$day24 = 19;$day25 = 20;$day26 = 21;$cycle5=0;$cycle6=1;$cycle7=2;$cycle8=3;$cycle9=4;$cycle10=5;$cycle11=6;$cycle12=7;$cycle13=8;$cycle14=9;$cycle1=10;$cycle2=11;$cycle3=12;$cycle4=13; if($now < $elvenportal){ $day1 = 4;$day2 = 3;$day3 = 2;$day4 = 1;$day5 = 0;$day6 = 25;$day7 = 24;$day8 = 23;$day9 = 22;$day10 = 21;$day11 = 20;$day12 = 19;$day13 = 18;$day14 = 17;$day15 = 16;$day16 = 15;$day17 = 14;$day18 = 13;$day19 = 12;$day20 = 11;$day21 = 10;$day19 = 12;$day22 = 9;$day23 = 8;$day24 = 7;$day25 = 6;$day26 = 5; $cycle5=0;$cycle6=13;$cycle7=12;$cycle8=11;$cycle9=10;$cycle10=9;$cycle11=8;$cycle12=7;$cycle13=6;$cycle14=5;$cycle1=4;$cycle2=3;$cycle3=2;$cycle4=1; }; $offset = $now-$elvenportal; $beyondportal = FLOOR($offset/60/60/24) ; ?> Now I tried to do a similar thing for the cycles like so: <?php if ($beyondportal % 364 == $cycle1 || abs($beyondportal) % 364 == $cycle1){ ?> <h4>Cycle 1</h4> <?php } ; ?> <?php if ($beyondportal % 364 == $cycle2 || abs($beyondportal) % 364 == $cycle2){ ?> <h4>Cycle 2</h4> <?php } ; ?> etc... up to 14 but this seems not to be the right approach any help would be really great thank you all
  5. I'm creating an alternative calendar system(non-gregorian) and so I need to know some basic math to figure some of this out and how to express it in php. the calendar year is 364 days long and it is split into 14 months that are 26 days long each. I have create a script that determines which day of 26 no problem, but getting the month is proving difficult. My code I'm using to display the content for each of the 26 days is as follows: <?php if ($beyondportal % 26 == $day1 || abs($beyondportal) % 26 == $day1){ ?> It's day 1 <?php } ; ?> <?php if ($beyondportal % 26 == $day2 || abs($beyondportal) % 26 == $day2){ ?> It's day 2 <?php } ; ?> etc... up to 26 here is the code that gives $beyondportal and the day variables their values <?php // gets todays date and compares it to 11.11.11, if its positive days get a certain set of values, if negative they get another $elvenportal = mktime(11,11,11,11,11,2011); $now = mktime(11,11,11,date("m"),date("d"),date("y")); $late = date("H"); if ($late < 5) {$now = mktime(11,11,11,date("m"),date("d")-1,date("y"));}; if ($_POST["dayz"] != "" ){ if ($_POST["month"] != "" ){ if ($_POST["year"] != "" ){ $now = mktime(11,11,11,$_POST["month"],$_POST["dayz"],$_POST["year"]); };};}; $day1 = 22;$day2 = 23;$day3 = 24;$day4 = 25;$day5 = 0;$day6 = 1;$day7 = 2;$day8 = 3;$day9 = 4;$day10 = 5;$day11 = 6;$day12 = 7;$day13 = 8;$day14 = 9;$day15 = 10;$day16 = 11;$day17 = 12;$day18 = 13;$day19 = 14;$day20 = 15;$day21 = 16;$day22 = 17;$day23 = 18;$day24 = 19;$day25 = 20;$day26 = 21;$cycle5=0;$cycle6=1;$cycle7=2;$cycle8=3;$cycle9=4;$cycle10=5;$cycle11=6;$cycle12=7;$cycle13=8;$cycle14=9;$cycle1=10;$cycle2=11;$cycle3=12;$cycle4=13; if($now < $elvenportal){ $day1 = 4;$day2 = 3;$day3 = 2;$day4 = 1;$day5 = 0;$day6 = 25;$day7 = 24;$day8 = 23;$day9 = 22;$day10 = 21;$day11 = 20;$day12 = 19;$day13 = 18;$day14 = 17;$day15 = 16;$day16 = 15;$day17 = 14;$day18 = 13;$day19 = 12;$day20 = 11;$day21 = 10;$day19 = 12;$day22 = 9;$day23 = 8;$day24 = 7;$day25 = 6;$day26 = 5; $cycle5=0;$cycle6=13;$cycle7=12;$cycle8=11;$cycle9=10;$cycle10=9;$cycle11=8;$cycle12=7;$cycle13=6;$cycle14=5;$cycle1=4;$cycle2=3;$cycle3=2;$cycle4=1; }; $offset = $now-$elvenportal; $beyondportal = FLOOR($offset/60/60/24) ; ?> Now I tried to do a similar thing for the cycles like so: <?php if ($beyondportal % 364 == $cycle1 || abs($beyondportal) % 364 == $cycle1){ ?> <h4>Cycle 1</h4> <?php } ; ?> <?php if ($beyondportal % 364 == $cycle2 || abs($beyondportal) % 364 == $cycle2){ ?> <h4>Cycle 2</h4> <?php } ; ?> etc... up to 14 but this seems not to be the right approach any help would be really great thank you all
  6. Hi there, My code here is meant to take the variable "$beyondportal" and see if it is a multiple of 26 counting from 0, then from 1, 2, 3 etc.. all the way to 25. if it's a multiple of 26 counting from 1, I get a set of content. If it's a multiple of 26 counting from 1, I get another all the way through 25. The code I wrote is working great if $beyond portal turns out to be a positive value, but if it's a negative value, this seems to be coming up wrong except for in the case of multiples of 26 counting up from 0 because -26 is the same distance as 26 from zero. Can someone see the pattern I'm getting at here? <?php if ($beyondportal % 26 == 0 || $beyondportal == 0 || abs($beyondportal) % 26 == 0){ ?> PURPLE <?php } ; ?> <?php if ($beyondportal % 26 == 1 || $beyondportal == 1|| abs($beyondportal) % 26 ==1){ ?> BLUE <?php } ; ?> <?php if ($beyondportal % 26 == 2 || $beyondportal == 2|| abs($beyondportal) % 26 ==2){ ?> GREEN <?php } ; ?> ETC... ETC.... up to: <?php if ($beyondportal % 26 == 25 || $beyondportal == 25|| abs($beyondportal) % 26 ==25){ ?> YELLOW <?php } ; ?> (my code on 1-25 is coming up incorrectly)
  7. This is my best guess. I'm really not clear what abs() does. <?php if ($beyondportal % 26 == 0 || $beyondportal == 0 || $beyondportal abs(26) == 0){ ?> MY CONTENT <?php } ; ?>
  8. how do you use abs() in this context?
  9. <?php if ($beyondportal % 26 == 0 || $beyondportal == 0){ ?> MY CONTENT <?php } ; ?> This code compares my variable $beyondportal and if it is a multiple of 26 counting up from 0, it prints my content. This is great but sometimes the number comes up a negative that is a multiple counting down from 0 like -26, -52, etc.. if I could do the opposite of a modulus I would think it would work but I'm not sure how to in php. any suggestions?
  10. I'm trying to compare $pastthedate to multiples of 26 - for example 0, 26, 52, etc.. and I have achieved this with the code below: <?php if ($pastthedate % 26 == 0 || $pastthedate == 0){ ?> DISPLAY MY CONTENT <?php } ; ?> Now I also want to display other content if $pastthedate equals multiples of of 26 starting at 1 - for example 1, 27, 53, etc.. and then so on, multiples of of 26 starting at 2 (2, 28, 54, etc..) and then so on, multiples of of 26 starting at 3 (3, 29, 55, etc..) "" starting at 4(4, 30, 56, etc..) "" starting at 5(4, 30, 56, etc..) all the way up to starting at 25 Any help would be greatly appreciated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.