FeedTime

Contents

[ hide ]

    The class FeedTime is a utility class provided by FeedWordPress which provides flexible and easy parsing of text date/time formats that are commonly used in feeds.

    Sample

     <?php
     // get the starting time from gd:when on a Google Calendar event
     $startTimes = $post->query('/gd:when/@startTime');
     if (count($startTimes) > 0) :
          // query() always returns an array
          foreach ($startTimes as $startTime) :
               $t = new FeedTime($time);
               $ts = $t->timestamp();
          endforeach;
     endif;
    

    // $ts now contains the Unix-epoch timestamp corresponding to the // date/time contained in the last <gd:when startTime="..."/> // attribute...

    $prettyDate = date('j F Y', $ts);

    Interface

     class FeedTime {
          function FeedTime ($time);
          // Constructor function. Accepts a text date/time to be parsed.
    

    function set ($time); // Setter function. Sets the text date/time to be parsed.

    function timestamp (); // Get the Unix-epoch timestamp corresponding to the text date/time.

    function failed (); // Returns TRUE if we were completely unable to parse the provided text. }
    This page is a Wiki! Log in or register an account to edit.

    Leave a Reply

    Your email address will not be published. Required fields are marked *