Return the {@link JDate} object

@param   mixed  $time      The initial time for the JDate object
@param   mixed  $tzOffset  The timezone offset.

@return  Date object

@see     Date
@since   11.1
505273
public static function getDate($time = 'now', $tzOffset = null)
	{
		static $classname;
		static $mainLocale;

		$language = self::getLanguage();
		$locale = $language->getTag();

		if (!isset($classname) || $locale != $mainLocale)
		{
			// Store the locale for future reference
			$mainLocale = $locale;

			if ($mainLocale !== false)
			{
				$classname = str_replace('-', '_', $mainLocale) . 'Date';

				if (!class_exists($classname))
				{
					// The class does not exist, default to JDate
					$classname = 'Date';
				}
			}
			else
			{
				// No tag, so default to JDate
				$classname = 'Date';
			}
		}

		$key = $time . '-' . ($tzOffset instanceof DateTimeZone ? $tzOffset->getName() : (string) $tzOffset);

		if (!isset(self::$dates[$classname][$key]))
		{
			self::$dates[$classname][$key] = new $classname($time, $tzOffset);
		}

		$date = clone self::$dates[$classname][$key];

		return $date;
	}
650199
public static String convertTz(String dateStr, String format, String tzFrom, String tzTo) {
		return dateFormatTz(toTimestampTz(dateStr, format, tzFrom), tzTo);
	}
645318
public static function createFromDateString($time)
    {
        $interval = parent::createFromDateString($time);
        if ($interval instanceof DateInterval && !($interval instanceof static)) {
            $interval = static::instance($interval);
        }

        return static::instance($interval);
    }
1104799
public function addTimestampsWithTimezone($createdAt = null, $updatedAt = null)
    {
        $this->addTimestamps($createdAt, $updatedAt, true);

        return $this;
    }
649239
public static function inFuture($date, $time = null)
    {
        if (is_null($time)) {
            $time = self::time();
        }
        if (!is_int($date)) {
            $date = self::strtotime($date);
        }

        return $time < $date;
    }
113278
public static function createFromFormat($format, $time, $object = null)
    {
        if ($object !== null) {
            $dt = parent::createFromFormat($format, $time, $object);
        } else {
            $dt = parent::createFromFormat($format, $time);
        }

        $lastErrors = parent::getLastErrors();

        if ($dt instanceof \DateTimeInterface) {
            return new static($dt->format('Y-m-d H:i:s.u'), $dt->getTimezone());
        }

        throw new \InvalidArgumentException(implode(PHP_EOL, $lastErrors['errors']));
    }
353389
public function getTimeDiff(DateTime $releaseDate)
    {
        $now = new DateTime();

        /** @var DateInterval $diff */
        $diff = $now->diff($releaseDate);

        if ($diff->days > 7) {
            return '';
        }

        if ($diff->days == 7) {
            return 'a week ago';
        }

        if ($diff->days >= 1) {
            return sprintf('%d day(s) ago', $diff->days);
        }

        if ($diff->h >= 1) {
            return sprintf('%d hour(s) ago', $diff->h);
        }

        if ($diff->i >= 1) {
            return sprintf('%d minute(s) ago', $diff->i);
        }

        return 'just now';
    }
476206
final public static function tzOffsetToName($offset, $isDst = null)
    {
        if ($isDst === null) {
            $isDst = date('I');
        }

        $offset *= 3600;
        $zone = timezone_name_from_abbr('', $offset, $isDst);

        if ($zone === false) {
            foreach (timezone_abbreviations_list() as $abbr) {
                foreach ($abbr as $city) {
                    if (((bool)$city['dst'] === (bool)$isDst) &&
                        (strlen($city['timezone_id']) > 0) &&
                        ($city['offset'] == $offset)
                    ) {
                        $zone = $city['timezone_id'];
                        break;
                    }
                }

                if ($zone !== false) {
                    break;
                }
            }
        }

        return $zone ?: date_default_timezone_get();
    }
832242
public static function createFromFormat($format, $date, $tz = null) {
        
        if ($tz !== null) {
            $tz = static::safeCreateDateTimeZone($tz);
        }
        
        $instance = new static($tz);
        
        $instance->parseFormat($format, $date);
        
        return $instance;
    }
192411
protected function getFormatedDateTime( Date $date = null, Time $time = null ) {
		$timestamp = null;
		if($date && $time) {
			$timestamp = strtotime($date . ' ' . $time);
		}
		else {
			$timestamp = time();
		}
		return gmdate('Ymd\THis\Z', $timestamp);
	}
638358
public static function createFromFormat( $format, $time, $timezone = null ) {

		/** @var \DateTimeInterface $created */
		$created = empty( $timezone ) ?
			parent::createFromFormat( $format, $time ) :
			parent::createFromFormat( $format, $time, $timezone );

		if ( false === $created ) {
			return false;
		}

		$wp_date_time = new static( '@' . $created->getTimestamp() );

		return $wp_date_time->setTimezone( $created->getTimezone() );
	}
781243
public static function createFromFormat($format, $time, $tz = null)
    {
        // First attempt to create an instance, so that error messages are based on the unmodified format.
        if ($tz !== null) {
            $date = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz));
        } else {
            $date = parent::createFromFormat($format, $time);
        }

        $lastErrors = parent::getLastErrors();

        if (($mock = static::getTestNow()) && ($date instanceof DateTime || $date instanceof DateTimeInterface)) {
            // Set timezone from mock if custom timezone was neither given directly nor as a part of format.
            // First let's skip the part that will be ignored by the parser.
            $nonEscaped = '(?<!\\\\)(\\\\{2})*';

            $nonIgnored = preg_replace("/^.*{$nonEscaped}!/s", '', $format);

            if ($tz === null && !preg_match("/{$nonEscaped}[eOPT]/", $nonIgnored)) {
                $tz = $mock->getTimezone();
            }

            // Prepend mock datetime only if the format does not contain non escaped unix epoch reset flag.
            if (!preg_match("/{$nonEscaped}[!|]/", $format)) {
                $format = static::MOCK_DATETIME_FORMAT.' '.$format;
                $time = $mock->format(static::MOCK_DATETIME_FORMAT).' '.$time;
            }

            // Regenerate date from the modified format to base result on the mocked instance instead of now.
            if ($tz !== null) {
                $date = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz));
            } else {
                $date = parent::createFromFormat($format, $time);
            }
        }

        if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
            $instance = static::instance($date);
            $instance::setLastErrors($lastErrors);

            return $instance;
        }

        throw new InvalidArgumentException(implode(PHP_EOL, $lastErrors['errors']));
    }
767796
public static function getTime($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);

		$time = $dt->format('H') * self::SECONDS_IN_AN_HOUR;
		$time += $dt->format('i') * self::SECONDS_IN_A_MINUTE;
		$time += $dt->format('s');

		return $dt->setTimestamp($time)->format($format);
	}
836010
public function tzFormat($format, $tz = null)
    {
        if (isset($tz)) {
            $this->setTimezone(new DateTimeZone($tz));
        }

        return $this->format($format);
    }
1264125
public function getDatetime($data, $timezone = null)
    {
        if ($data instanceof \DateTime) {
            return $data;
        }

        if ($data instanceof \DateTimeImmutable) {
            return \DateTime::createFromFormat(\DateTime::ATOM, $data->format(\DateTime::ATOM));
        }

        // the format method accept array or integer
        if (is_numeric($data)) {
            $data = (int) $data;
        }

        if (\is_string($data)) {
            $data = strtotime($data);
        }

        $date = new \DateTime();
        $date->setTimestamp($data);
        $date->setTimezone(new \DateTimeZone($timezone ?: $this->timezoneDetector->getTimezone()));

        return $date;
    }
1177636
public static function formatTimestamp($timestamp, $format = self::DEFAULT_TIME_FORMAT, $timezone = self::DEFAULT_TIMEZONE)
    {
        $dateTime = new DateTime();
        $dateTime->setTimestamp($timestamp);
        $dateTime->setTimezone(new DateTimeZone($timezone));
        return $dateTime->format($format);
    }
532052
public static function createFromFormat($format, $time, $timezone = null)
    {
        if (null === $timezone) {
            $timezone = self::getServerTimezone();
        }

        if (null === $timezone) {
            // This is necessary due to how native DateTime handles passing null for a timezone (it doesnt)
            $parent = parent::createFromFormat($format, $time);
        } else {
            $parent = parent::createFromFormat($format, $time, $timezone);
        }

        if (empty($parent)) {
            throw new TypeException('Could not create DateTime from the given format');
        }

        $datetime = new self('@' . $parent->getTimestamp());
        if (null !== $timezone) {
            $datetime->setTimezone($timezone);
        }

        return $datetime;
    }