rss - Defining previous post time php -


i have listing of calendar events. right now, posts day if different previous day. sunday events list under 1 "sunday" heading, etc. trying set time heading act same way. i.e., list time once, , corresponding events underneath heading. how define previous time, can echo time if it's new time?

<?php             $started_loop = false;             $previousday = 0;             $sameday = false;             foreach($this->occurrences->channel->item $occurrence) {                  // extract time stamp description                 $day = $this->gettimestampfromdescription($occurrence->description);                 $imageurl = $this->getimgurlfromdescription($occurrence->description);                  $daydate = date('d', $day);                 $sameday = ( ($daydate == $previousday) ? true : false);    // set whether or not post same day last 1                                                if($n > $max_events)                     break;              // stop loop if we've reached maximum number of allowable events                  ?>                  <!-- second eventful day of week (identical) -->                 <div class="row-fluid">                      <div class="span9">                     <h3 class="event_week_day"><?php if (!$sameday) echo date('l, m j',$day); ?></h3>                          <!-- first event day -->                         <a href="<?php echo $occurrence->link ?>">                             <p class="event_week_single">                                 <b><?php echo(date('g:i ',$day) )?></b><br><?php echo ($occurrence->title); ?>                             </p>                         </a>                      </div>                 </div> 

replace:

$previousday = 0; $sameday = false;  ...  $daydate = date('d', $day); $sameday = ( ($daydate == $previousday) ? true : false);  ...  <?php echo(date('g:i ',$day) )?> 

with:

$previousday = 0; $previoushour = 0; $sameday = false; $samehour = false;  ...  $daydate = date('d', $day); $dayhour = date('g:i a', $day); if ( $daydate == $previousday ) {     $sameday = true; else {     $sameday = false;     $previoushour = 0;     $previousday = $daydate; } if ( $dayhour == $previoushour ) {     $samehour = true; else {     $samehour = false;     $previoushour = $dayhour; }  ...  <?php if (!$samehour) { echo date('g:i ',$day); } ?> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -