Horde_Date::datestamp PHP Method

datestamp() public method

Returns the unix timestamp representation of this date, 12:00am.
public datestamp ( ) : integer
return integer A unix timestamp.
    public function datestamp()
    {
        if ($this->_year >= 1970 && $this->_year < 2038) {
            return mktime(0, 0, 0, $this->_month, $this->_mday, $this->_year);
        }
        $date = new DateTime($this->format('Y-m-d'));
        return $date->format('U');
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Saves the txt_datavalue or int_datavalue depending on context.
  *
  * Folds special data types into a serializable, preferably search-friendly
  * format.
  */
 public function setDataValue($value)
 {
     /* These field-specific handlers should better be delegated to field
      * definitions. */
     switch ($this->property->datatype) {
         case 'date':
         case 'datetime':
         case 'hourminutesecond':
         case 'monthdayyear':
         case 'monthyear':
         case 'time':
             if (is_array($value)) {
                 // Directly passing the array makes funny breakage :(
                 $dt = new Horde_Date();
                 foreach ($value as $marker => $content) {
                     if (strlen($content)) {
                         $dt->{$marker} = $content;
                     }
                 }
                 $value = $dt->datestamp();
             }
             break;
         case 'image':
             $value = $value['hash'];
             break;
     }
     return $this->txt_datavalue = $value;
 }
All Usage Examples Of Horde_Date::datestamp