Returns a timestamp for 0:00:00 of the date of the time

@param mixed  $ts     Date/time value
@param string $format Format of the return value
@return string
168057
public static function getDayStart($ts = 'now', $format = 'U', $tz = null) {
		if (!Util::isValidTimezone($tz)) {
			$tz = Util::getClientTimezone();
		}
		
		$dt = new DateTime(null, new DateTimeZone($tz));
		(is_int($ts)) ? $dt->setTimestamp($ts) : $dt->modify($ts);
		$dt->setTime(0, 0, 0);
		return $dt->format($format);
	}
729921
public function convertTimestamp($date, $format)
    {
        if (! is_numeric($date)) {
            $date = strtotime($date);
        }
        
        return $this->getDt()
            ->createFromTimestamp($date, $this->getTz())
            ->format($format);
    }
1039210
public static function time( $format = false )
	{	
		$time = microtime( true ) - CCF_PROFILER_TME;
		
		if ( $format )
		{
			return CCStr::microtime( $time );
		}
		
		return $time;
	}
1238211
protected function formatDate($ts) {
		if ($ts > $this->today) {
			return 'Today '.date($this->options['timeFormat'], $ts);
		}
		
		if ($ts > $this->yesterday) {
			return 'Yesterday '.date($this->options['timeFormat'], $ts);
		} 
		
		return date($this->options['dateFormat'], $ts);
	}
1167871
private function validateFormat($format)
    {
        if (isset($this->formatsDate[$format])) {
            return $this->formatsDate[$format];
        }
        if (isset($this->formatsTime[$format])) {
            return $this->formatsTime[$format];
        }
        $format = strtolower($format);
        if (isset($this->formatsDate[$format])) {
            return $this->formatsDate[$format];
        }
        if (isset($this->formatsTime[$format])) {
            return $this->formatsTime[$format];
        }
    }
271924
public static function clearDate($ts = null)
	{
		// default to now
		if ($ts === null) $ts = sfDateTimeToolkit::now();
		
		list($H, $i, $s, $m, $d, $Y) = sfDateTimeToolkit::breakdown($ts);
		
		return mktime($H, $i, $s, 0, 0, 0);
	}
1321903
public static function DateFull($Timestamp, $Format = '') {
      if ($Timestamp === NULL)
         return T('Null Date', '-');

      // Was a mysqldatetime passed?
      if (!is_numeric($Timestamp)) {
         $Timestamp = self::ToTimestamp($Timestamp);
      }
         
      if (!$Timestamp)
         $Timestamp = time(); // return '&#160;'; Apr 22, 2009 - found a bug where "Draft Saved At X" returned a nbsp here instead of the formatted current time.
      $GmTimestamp = $Timestamp;

      $Now = time();
      
      // Alter the timestamp based on the user's hour offset
      $Session = Gdn::Session();
      if ($Session->UserID > 0) {
         $SecondsOffset = ($Session->User->HourOffset * 3600);
         $Timestamp += $SecondsOffset;
         $Now += $SecondsOffset;
      }

      $Html = FALSE;
      if (strcasecmp($Format, 'html') == 0) {
         $Format = '';
         $Html = TRUE;
      }
      
      $FullFormat = T('Date.DefaultDateTimeFormat', '%c');

      $Result = strftime($FullFormat, $Timestamp);

      if ($Html) {
         $Result = Wrap($Result, 'time', array('title' => strftime($FullFormat, $Timestamp), 'datetime' => gmdate('c', $GmTimestamp)));
      }
      return $Result;
   }
1075641
public function getTime($format = null)
    {
        //argument 1 must be a string or null
        Argument::i()->test(1, 'string', 'null');

        $time = $this->time + $this->offset;

        if (!is_null($format)) {
            return date($format, $time);
        }

        return $time;
    }
980785
public function getTimestamp($format = self::TIMESTAMP_FORMAT_RFC1123) {
		$this->ensureInput();
		if(!isset($this->input['timestamp'])) return null;
		switch($format) {
			case static::TIMESTAMP_FORMAT_UNIX:
				return strtotime($this->input['timestamp']);
			case static::TIMESTAMP_FORMAT_RFC1123:
			default:
				return $this->input['timestamp'];
		}
	}
1195047
public function timeAgo($time = null, $format = null) {
		if (empty($time)) {
			$time = time();
		}
		if (empty($format)) {
			$format = '%x %X';
		}

		$result = $this->Html->tag(
			'time',
			$this->Time->i18nFormat($time, $format),
			[
				'data-toggle' => 'timeago',
				'datetime' => date('c', $this->Time->fromString($time)),
				'class' => 'help'
			]
		);

		return $result;
	}
412797
public function getTransferDate($format = null)
    {
        $node = $this->getFirst('//epp:epp/epp:response/epp:resData/domain:infData/domain:trDate');
        if ($node === null) {
            return null;
        }

        if ($format === null) {
            return $node->nodeValue;
        }

        return date_create_from_format($format, $node->nodeValue);
    }
242438
public function setTimeFormat($format) {
        if (is_string($format)) {
            $this->timeFormatter = function ($t) use ($format) {
                return strftime($format, $t);
            };
        } else {
            $this->timeFormatter = $format;
        }

        return $this;
    }
732450
public static function toDbFormat($format = "Y-m-d H:i:s", $timestamp = null)
    {
        if ($timestamp === null) {
            $timestamp = time();
        }
        return date($format, $timestamp);
    }
677607
public static function date($format = "Y-m-d H:i:s", $time = null)
    {
        $time = ($time !== null ? $time : time());

        if (!is_numeric($time)) {
            $time = static::toUnix($time);
        }

        return date($format, $time);
    }
469793
public function Format($format)
    {
        if (!$this->value) {
            return null;
        }
        $formatter = $this->getFormatter();
        $formatter->setPattern($format);
        return $formatter->format($this->getTimestamp());
    }
559101
protected function formatDatetime($timestamp = 0, $format = '')
    {
        switch ($this->timeset) {
            case 1:
                // swatch date
            return $this->swatchDate($timestamp).' � '.$this->swatchTime($timestamp);
            break;
            case 2:
                // iso date
            return $this->unixTimestampToISOdatetime($timestamp);
            break;
            default:
                // default time
            return date($this->dateFilter($format, $timestamp), $timestamp);
            break;
        }
    }
31441
public function format($format = '')
  {
    if ( !empty($format) ){
      return $this->time->format($format);
    }
    else { 
      return $this->time->format('Y-m-d H:i:s');
    }
  }