CreateDateTime
@param object $dateArg
@param object $timeArg
@return object
160123
public static function CreateDateTime( $dateArg, $timeArg )
	{
		if ( $dateArg instanceof Undefined || $timeArg instanceof Undefined )
		{
			return Undefined::getValue();
		}

		if ( $dateArg instanceof DOMXPathNavigator )
		{
			$value = $dateArg->getValue();
			// Get the type of the element
			$dateArg = strpos( $value, "T") === false
				? DateValue::Parse( $value )
				: DateTimeValue::Parse( $value );
		}
		/**
		 * @var DateValue $date
		 */
		$date = $dateArg;

		/**
		 * @var TimeValue $time
		 */
		$time = $timeArg instanceof DOMXPathNavigator
			? TimeValue::Parse( $timeArg->getValue() )
			: $timeArg;

		$microseconds = empty( $time->Value->microseconds ) ? "" : "." . $time->Value->microseconds;
		$offsetChar = "";
		if ( ! $date->IsLocal || ! $time->IsLocal )
		{
			$value = $date->IsLocal
				? $time
				: $date;

			/**
			 * @var \DateTimeZone $dtz
			 */
			$dtz = $value->Value->getTimezone();

			$offsetChar = $dtz->getName() == "Z"
				? "\Z"
				: "P";
			$offsetChar = $dtz->getName();

		    if ( ! $date->IsLocal && ! $time->IsLocal )
		    {
			   if ( $date->Value->getOffset() != $time->Value->getOffset() )
				  throw XPath2Exception::withErrorCode( "FORG0008", Resources::FORG0008 );
			   // $dtz = $date->Value->getTimezone();
		    }
		}

		// Allow for the time to have been entered as 24:00:00 so as a DateTime object it will be 1T00:00:00
		// $timeDays = $time->Value->format("z");
		// if ( $timeDays )
		// {
		//	$date = DateTimeValue::AddDayTimeDuration( $date, DayTimeDurationValue::Parse("P{$timeDays}D") );
		// }

		// $dtv = DateTimeValue::Parse( $date->Value->format("Y-m-d") . "T" . $time->Value->format("H:i:s$microseconds$offsetChar") );
		$dtv = DateTimeValue::Parse( $date->Value->format("Y-m-d") . "T" . $time->Value->format("H:i:s$microseconds") . $offsetChar );
		// BMS 2018-03-23 Changed to this.  Handles test case 48230 V-05.
		// 				  The XPath 2.0 specification is clear that these two are equivalent and event give an example:
		//						fn:dateTime(xs:date('2018-03-23'),xs:time('00:00:00'))
		//						fn:dateTime(xs:date('2018-03-23'),xs:time('24:00:00'))
		//				  That is, '00:00:00' and '24:00:00' are synonyms for midnight at the beginning of the day.
		//				  But the XBRL test uses '24:00:00' as midnight of the end of the day.
		global $use_xbrl_functions;
		// BMS 2018-06-08	This has been changed because relying on 23:00 was never
		//					going to work and on another machine (Linux) it didn't.
		//					Now if the hours are "00" but there is a non-zero timestamp
		//					the assumption is the user meant midnight.
		// if ( $use_xbrl_functions && $time->Value->getTimestamp() == 82800 )
		if ( $use_xbrl_functions && ( ( $x = $time->Value->getTimestamp() ) > 0  && $x <= 86400 ) && $time->Value->format("H") == "00" )
		{
			$dtv->Value->add( new \DateInterval("P1D") );
		}
		$dtv->S = $date->S;

		return $dtv;
	}
600226
public function prePersist(LifecycleEventArgs $eventArgs)
    {
        $entity = $eventArgs->getObject();

        if (!$this->hasTrait($entity, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) {
            return;
        }

        $this->logger->debug(
            '[TimestampableListener] Entering TimestampableListener for « prePersist » event'
        );

        $now = new DateTime('NOW');
        $entity->setCreatedAt($now);
        $entity->setUpdatedAt($now);
    }
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;
    }
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);
    }
771243
public function fromRedisTimestamp($timestamp) : DateTime
    {
        $date = DateTime::createFromFormat('U', $timestamp);
        $date->setTimezone(new DateTimeZone(date_default_timezone_get()));

        return $date;
    }
965560
def to_datetime(arg):
    


    if isinstance(arg, datetime.datetime):
        return arg
    elif arg == 0:
        return datetime.datetime.now()
    elif isinstance(arg, str):
        if arg == "now":
            arg = datetime.datetime.now()
        elif arg == "?":
            arg = datetime.datetime(1970, 1, 1)
        else:
            arg = str2dt(arg)
    elif isinstance(arg, datetime.date):
        arg = date2datetime(arg)
    elif isinstance(arg, (int, float)):
        # Suppose it is a timestamp
        arg = ts2dt(arg)
    else:
        raise TypeError("Wrong type for argument 'arg': {}".format(arg.__class__.__name__))

    return arg
655755
public static function createFromRow(array $row, $dateTimeFormat)
    {
        $result = new static();
        $result->id = empty($row['lcirID']) ? null : (int) $row['lcirID'];
        $result->ipRange = IPFactory::rangeFromBoundaries($row['lcirIpFrom'], $row['lcirIpTo']);
        $result->type = (int) $row['lcirType'];
        $result->expires = empty($row['lcirExpires']) ? null : DateTime::createFromFormat($dateTimeFormat, $row['lcirExpires']);

        return $result;
    }
605471
public static function createFromFormat($time, $format = null)
    {
        if (self::isNull($format)) {
            $format = self::$defaultFormat;
        }

        try {
            $date = \DateTime::createFromFormat($format, $time);
            if (!$date) {
                throw new DateTimeObjectException(DateTimeObjectException::MSG_UNABLE_TO_CREATE_FROM_FORMAT);
            }
        } catch (\Exception $e) {
            throw new DateTimeObjectException(DateTimeObjectException::MSG_UNABLE_TO_CREATE_FROM_FORMAT);
        }

        try {
            $dt = new DateTimeObject();
            $dt->setTimestamp($date->getTimestamp());
            $dt->setFormat($format);
        } catch (\Exception $e) {
            throw new DateTimeObjectException(DateTimeObjectException::MSG_UNABLE_TO_CREATE_FROM_FORMAT);
        }

        return $dt;
    }
341032
public static function fromTimestamp($timestamp)
    {
        try {
            $dateTime = new DateTime("@{$timestamp}");

            return static::fromDateTime($dateTime);
        } catch (Exception $e) {
            throw new InvalidArgumentValue('$timestamp', $timestamp, __CLASS__, $e);
        }
    }
188569
public static function createFromFormat($format, $time, $timezone = null)
    {
        if ($timezone === null) {
            $timezone = new DateTimeZone(date_default_timezone_get());
        }

        $datetime = \DateTime::createFromFormat($format, $time, $timezone);

        return new self($datetime->format(DateTime::ISO8601), $timezone);
    }
991340
public function create($format, $time)
    {
        return Date::createFromFormat($format, $time, $this->cachetTimezone)->setTimezone($this->appTimezone);
    }
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);
    }
809247
public function createdAtDatetime()
    {
        return $this->entity->created_at->setTimezone($this->config->get('config.timezone'))
                                        ->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format'));
    }
1324006
public function setCreatedAtAttribute($createdAt)
    {
        if (!$createdAt) {
            return;
        }

        if (!$createdAt instanceof DateTime) {
            $createdAt = Carbon::parse($createdAt);
        }

        $timestamp = $createdAt->format('U');
        $timestamp = 30 * round($timestamp / 30);

        $date = Carbon::createFromFormat('U', $timestamp)->toDateTimeString();

        $this->attributes['created_at'] = $date;

        return $date;
    }
794336
public static function createDateFromTimestamp($timestamp, DateTimeZone $dateTimeZone = NULL) {
    $openYLocaleDate = new OpenYLocaleDate();
    $openYLocaleDate->setDateFromTimeStamp($timestamp, $dateTimeZone);
    return $openYLocaleDate;
  }
935337
public static function newFromTimeString($timeString)
	{
        try {
    		$dateTime = new DateTime($timeString);
        } catch(\Exception $e) {
            throw new InvalidArgumentException('Time string must be valid, see DateTime for documentation');
        }
		return new self($dateTime->format('G'), $dateTime->format('i'));
	}
411735
public static function createFromFormat($format, $time, $tz = null)
    {
        if ($tz !== null) {
            $dt = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz));
        } else {
            $dt = parent::createFromFormat($format, $time);
        }

        if ($dt instanceof DateTimeInterface) {
            return static::instance($dt);
        }

        $errors = static::getLastErrors();
        throw new InvalidArgumentException(implode(PHP_EOL, $errors['errors']));
    }