Convert date from unix -> mysql
@param integer $dateNum
@return string
350505
public static function unixtime2Sql($dateNum)
	{
		// 31/01/2016 20:20:00 --> 2016-01-31 00:00
		if ($dateNum == null) {
			return DaoOne::$dateEpoch;
		}
		try {
			$date2 = new DateTime(date("Y-m-d H:i:s.u", $dateNum));
		} catch (Exception $e) {
			return DaoOne::$dateEpoch;
		}
		return $date2->format('Y-m-d H:i:s.u');
	}
1182747
public static function unix2dos($timestamp = 0)
    {
        $timestamp = ! $timestamp ? getdate() : getdate($timestamp);

        if ($timestamp['year'] < 1980)
        {
            return (1 << 21 | 1 << 16);
        }

        $timestamp['year'] -= 1980;

        return ($timestamp['year'] << 25 | $timestamp['mon'] << 21 |
            $timestamp['mday'] << 16 | $timestamp['hours'] << 11 |
            $timestamp['minutes'] << 5 | $timestamp['seconds'] >> 1);
    }
1315718
protected function formatDateCellValue($node)
    {
        // The XML node looks like this:
        // <table:table-cell calcext:value-type="date" office:date-value="2016-05-19T16:39:00" office:value-type="date">
        //   <text:p>05/19/16 04:39 PM</text:p>
        // </table:table-cell>

        if ($this->shouldFormatDates) {
            // The date is already formatted in the "p" tag
            $nodeWithValueAlreadyFormatted = $node->getElementsByTagName(self::XML_NODE_P)->item(0);
            return $nodeWithValueAlreadyFormatted->nodeValue;
        } else {
            // otherwise, get it from the "date-value" attribute
            try {
                $nodeValue = $node->getAttribute(self::XML_ATTRIBUTE_DATE_VALUE);
                return new \DateTime($nodeValue);
            } catch (\Exception $e) {
                return null;
            }
        }
    }
666023
private function getMonthTitle( int $monthnum = 0 ) {
		global $wp_locale;
		$date_format = get_option('date_format');
		if ( in_array( $date_format, [
			'DATE_COOKIE',
			'DATE_RFC822',
			'DATE_RFC850',
			'DATE_RFC1036',
			'DATE_RFC1123',
			'DATE_RFC2822',
			'DATE_RSS'
		] ) ) {
			$month_format = 'M';
		} elseif ( in_array( $date_format, [
			'DATE_ATOM',
			'DATE_ISO8601',
			'DATE_RFC3339',
			'DATE_W3C'
		] ) ) {
			$month_format = 'm';
		} else {
			preg_match('/(^|[^\\\\]+)(F|m|M|n)/', str_replace( '\\\\', '', $date_format ), $m );
			if ( isset( $m[2] ) ) {
				$month_format = $m[2];
			} else {
				$month_format = 'F';
			}
		}

		switch ( $month_format ) {
			case 'F' :
				$month = $wp_locale->get_month( $monthnum );
				break;
			case 'M' :
				$month = $wp_locale->get_month_abbrev( $wp_locale->get_month( $monthnum ) );
				break;
			default :
				$month = $monthnum;
				break;
		}

		return $month;
	}
907743
function parseDSN($dsn) {
	 	if (is_array($dsn)) {
			return $dsn;
		} else {
		 	$dsn_match = "|^(?P<phptype>.*?)://(?P<parameters>.*?)/(?P<db>.*?)$|i";
		 	$parameter_match = "|^(?P<username>.*?):(?P<password>.*?)@(?P<hostspec>.*?)$|i";
		 	$args_match = '|^(?P<database>.*?)\?(?P<args>.*?)$|';

		 	/* First, pick out the phptype, database, and gunk in the middle */
			preg_match($dsn_match,$dsn,$matches['base']);
			/* Next, parse the gunk in the middle into username, host, and password */
			if (!empty($matches['base']['parameters'])) { preg_match($parameter_match,$matches['base']['parameters'],$matches['parameters']); }
			/* Then, parse the database to see if any commandline parameters were passed */
			if (substr_count($matches['base']['db'],"?") > 0) { preg_match($args_match,$matches['base']['db'],$matches['args']); }

			$retn = array();
			$retn['phptype'] = $matches['base']['phptype'];
			if (!empty($matches['base']['parameters']) && is_array($matches['parameters'])) {
			 	$retn['username'] = $matches['parameters']['username'];
			 	$retn['password'] = $matches['parameters']['password'];
			 	$retn['hostspec'] = $matches['parameters']['hostspec'];
			}
			if (!empty($matches['args']) && is_array($matches['args'])) {
			 	$retn['database'] = $matches['args']['database'];
			 	$retn['args'] = $this->parseDSN_args($matches['args']['args']);
			} else {
			 	$retn['database'] = $matches['base']['db'];
			}
			return $retn;
		}
    }
675511
public function getDateOfBirth() : ?DateTime
     {
        $rtn = $this->data['date_of_birth'];

        if (!empty($rtn)) {
            $rtn = new DateTime($rtn);
        }

        return $rtn;
     }
1307170
public function formatDateTime($value): \DateTime
    {
        if ($value instanceof \DateTime) {
            return $value;
        }

        if (is_numeric($value)) {
            $date = new \DateTime();
            $date->setTimestamp((int) $value);

            return $date;
        } elseif (null === $value) {
            return new \DateTime();
        }

        return new \DateTime($value);
    }
957395
public static function convert($number)
    {
        $number = preg_replace('/\,/i', '', $number);

        $number = preg_replace('/([^0-9\.\-])/i', '', $number);

        if (! is_numeric($number)) {
            return '0.00';
        }

        $isCents = (bool) preg_match('/^0.\d+$/', $number);

        return ($isCents ? '0' : null).number_format($number * 100., 0, '.', '');
    }
1062660
protected static function process(int $jdn): array
    {
        $r = (($jdn - 1723856) % 1461);
        $n = ($r % 365) + 365 * (int) ($r / 1460);

        $year = 4 * (int) (($jdn - 1723856) / 1461) +
            (int) ($r / 365) - (int) ($r / 1460);
        $month = (int) ($n / 30) + 1;
        $day = ($n % 30) + 1;

        return compact('day', 'month', 'year');
    }
827533
public function getDateFormat($field)
    {
        if ($this->_snapshot && isset($this->_snapshot[$field])) {
            $ts = is_numeric($this->_snapshot[$field]);
        } elseif (isset($this->$field)) {
            $ts = is_numeric($this->$field);
        } else {
            $ts = in_array($field, $this->getIntFields(), true);
        }
        return $ts ? 'U' : 'Y-m-d H:i:s';
    }
188018
public static function getDateSQLToForm($datetime)
    { 
        //YYYY-mm-dd
        $t = $this->splitDate($datetime, false);

        return $t['date'] . '/' . $t['month'] . '/' . $t['year'];
    }
563405
protected function formatDate($value)
    {
        $format = null;
        if (isset($this->input) && $this->input->hasOption('date-fmt')) {
            $format = $this->input->getOption('date-fmt');
        }
        if ($format === null) {
            $format = $this->config->getWithDefault('application.date_format', 'c');
        }

        // Workaround for the ssl.expires_on date, which is currently a
        // timestamp in milliseconds.
        if (substr($value, -3) === '000' && strlen($value) === 13) {
            $value = substr($value, 0, 10);
        }

        $timestamp = is_numeric($value) ? $value : strtotime($value);

        return $timestamp === false ? null : date($format, $timestamp);
    }
312063
public function set(int $jdn)
    {
        if (!$this->isValidInteger($jdn)) {
            throw new InvalidDateException();
        }

        $this->jdn = $jdn;

        $date = static::process($jdn);

        return $this->setDate($date);
    }
1047718
def _convert_date(self, date):
        """'"""
        return '/'.join([str(int(date.split('/')[0]) + 1911)] + date.split('/')[1:])
716608
static function convert($input,$outputFormat=self::PHP) {
		if ($input===false) {
			$input=time();
		}

		if ($input instanceof \DateTime) {
			if ($outputFormat===self::INT) return $input->getTimestamp();
			if (is_string($outputFormat)) return date($outputFormat,$input->getTimestamp());
			if ($outputFormat===self::PHP) return $input;
			return null;
		}

		if (!is_numeric($input)) {
			$origInput = $input;
			$input=@strtotime($input);
			if ($input === false or $input === -1) {
				$input = str_replace(" ","",$origInput); // Helps with formats like 13. 5. 2013
				$input=@strtotime($input);
				if ($input === false or $input === -1) {
					throw new \InvalidArgumentException("Invalid input to Time::convert: $origInput");
				}
			}
		}

		if ($outputFormat===self::INT) return $input;
		if (is_string($outputFormat)) return date($outputFormat,$input);
		if ($outputFormat===self::PHP) {
			$d=new \DateTime();
			return $d->setTimestamp($input);
		}
		return null;
	}
1232732
public static function parseTime($input)
    {
        if ($input) {
            if (strlen($input) == 2) {
                $input .= ':00:00';
            }

            if (strlen($input) == 1) {
                $input = '0' . $input . ':00:00';
            }

            $dateTime = strtotime($input);
            return date('H:i:s', $dateTime);
        } else {
            return '00:00:00';
        }
    }
5541
public static function unixToJd($timestamp)
    {
        if ($timestamp < 0) {
            return false;
        } else {
            // Convert timestamp based on local timezone
            return self::GregorianToJd(gmdate('n', $timestamp), gmdate('j', $timestamp), gmdate('Y', $timestamp));
        }
    }