[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/IXR/ -> class-IXR-date.php (source)

   1  <?php
   2  
   3  /**
   4   * IXR_Date
   5   *
   6   * @package IXR
   7   * @since 1.5.0
   8   */
   9  class IXR_Date {
  10      var $year;
  11      var $month;
  12      var $day;
  13      var $hour;
  14      var $minute;
  15      var $second;
  16      var $timezone;
  17  
  18      /**
  19       * PHP5 constructor.
  20       */
  21      function __construct( $time )
  22      {
  23          // $time can be a PHP timestamp or an ISO one
  24          if (is_numeric($time)) {
  25              $this->parseTimestamp($time);
  26          } else {
  27              $this->parseIso($time);
  28          }
  29      }
  30  
  31      /**
  32       * PHP4 constructor.
  33       */
  34  	public function IXR_Date( $time ) {
  35          self::__construct( $time );
  36      }
  37  
  38      function parseTimestamp($timestamp)
  39      {
  40          $this->year = gmdate('Y', $timestamp);
  41          $this->month = gmdate('m', $timestamp);
  42          $this->day = gmdate('d', $timestamp);
  43          $this->hour = gmdate('H', $timestamp);
  44          $this->minute = gmdate('i', $timestamp);
  45          $this->second = gmdate('s', $timestamp);
  46          $this->timezone = '';
  47      }
  48  
  49      function parseIso($iso)
  50      {
  51          $this->year = substr($iso, 0, 4);
  52          $this->month = substr($iso, 4, 2);
  53          $this->day = substr($iso, 6, 2);
  54          $this->hour = substr($iso, 9, 2);
  55          $this->minute = substr($iso, 12, 2);
  56          $this->second = substr($iso, 15, 2);
  57          $this->timezone = substr($iso, 17);
  58      }
  59  
  60      function getIso()
  61      {
  62          return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
  63      }
  64  
  65      function getXml()
  66      {
  67          return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
  68      }
  69  
  70      function getTimestamp()
  71      {
  72          return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
  73      }
  74  }


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref