StartMin and StartMax passed variables not working

2 messages Options
Embed this post
Permalink
kwylez

StartMin and StartMax passed variables not working

Reply Threaded More More options
Print post
Permalink
If I pass into startMin and startMax a literal string then I receive a list of all my events, but if a dynamically create the date and pass into startMin and startMax a variable I don't see the calendar events.

Below is the code:

       <?php
        require_once 'Zend/Loader.php';
        Zend_Loader::registerAutoload();
          /*
           * $lastday = mktime(0, 0, 0, 3, 0, 2000);
           * echo strftime("Last day in Feb 2000 is: %d", $lastday);
           */
          $startDate = date("Y-m-d");
          $currMonth = date("m");
          $currYear  = date("Y");
          $lastday   = mktime(0, 0, 0, $currMonth, 0, $currYear);
          $endDay    = strftime("%d", $lastday);
          $endDate   = date($currYear."-".$currMonth."-".$endDay);
         
          $service = new Zend_Gdata_Calendar();
          $query = $service->newEventQuery();
          $query->setUser("username%40gmail.com");
          $query->setVisibility('public');
          $query->setProjection('full');
          $query->setOrderby('starttime');
          $query->setSortorder('ascending');
          $query->setStartMin($startDate);
          $query->setStartMax($endDate);
          /**
            *  The below literal strings work
            */
//          $query->setStartMin("2008-01-31");
//          $query->setStartMax("2008-02-03");

          $query->setFutureevents(false);

          // Retrieve the event list from the calendar server
          try {
            $eventFeed = $service->getCalendarEventFeed($query);
          } catch (Zend_Gdata_App_Exception $e) {
            print $e->getResponse()->getBody();
          }
        ?>
        <ul>
        <?php
        foreach ($eventFeed as $event):
          foreach ($event->getWhen() as $when):
        ?>
          <h4><?=substr($when->startTime, 0, 10)?></h4>
          <li>content?>"><?=$event->title?></li>
        <?php
          endforeach;
        ?>
        <?php
        endforeach;
        ?>
        </ul>
Bradley Holt

Re: StartMin and StartMax passed variables not working

Reply Threaded More More options
Print post
Permalink
The signature for the PHP date function is:

string date  ( string $format  [, int $timestamp  ] )

In your end date it looks like you're trying to pass the timestamp as the first argument:

$endDate   = date($currYear."-".$currMonth."-".$endDay);

Also, the timestamp should be a Unix timestamp, not an ISO 8601 date.

Regardless, I'd recommend using Zend_Date instead.

On Jan 31, 2008 11:00 AM, kwylez <[hidden email]> wrote:

If I pass into startMin and startMax a literal string then I receive a list
of all my events, but if a dynamically create the date and pass into
startMin and startMax a variable I don't see the calendar events.

Below is the code:

      <?php
       require_once 'Zend/Loader.php';
       Zend_Loader::registerAutoload();
         /*
          * $lastday = mktime(0, 0, 0, 3, 0, 2000);
          * echo strftime("Last day in Feb 2000 is: %d", $lastday);
          */
         $startDate = date("Y-m-d");
         $currMonth = date("m");
         $currYear  = date("Y");
         $lastday   = mktime(0, 0, 0, $currMonth, 0, $currYear);
         $endDay    = strftime("%d", $lastday);
         $endDate   = date($currYear."-".$currMonth."-".$endDay);

         $service = new Zend_Gdata_Calendar();
         $query = $service->newEventQuery();
         $query->setUser("username%40gmail.com");
         $query->setVisibility('public');
         $query->setProjection('full');
         $query->setOrderby('starttime');
         $query->setSortorder('ascending');
         $query->setStartMin($startDate);
         $query->setStartMax($endDate);
         /**
           *  The below literal strings work
           */
//          $query->setStartMin("2008-01-31");
//          $query->setStartMax("2008-02-03");

         $query->setFutureevents(false);

         // Retrieve the event list from the calendar server
         try {
           $eventFeed = $service->getCalendarEventFeed($query);
         } catch (Zend_Gdata_App_Exception $e) {
           print $e->getResponse()->getBody();
         }
       ?>
       <ul>
       <?php
       foreach ($eventFeed as $event):
         foreach ($event->getWhen() as $when):
       ?>
         <h4><?=substr($when->startTime, 0, 10)?></h4>
         <li> # content?>"><?=$event->title?> </li>
       <?php
         endforeach;
       ?>
       <?php
       endforeach;
       ?>
       </ul>
--
View this message in context: http://www.nabble.com/StartMin-and-StartMax-passed-variables-not-working-tp15207187s16154p15207187.html
Sent from the Zend gdata mailing list archive at Nabble.com.




--
Bradley Holt
[hidden email]