date_create example


    public function prepareSeoConfigForSaving(array $data)
    {
        trigger_error(sprintf('%s:%s is deprecated since Shopware 5.6 and will be private with 5.8.', __CLASS__, __METHOD__), E_USER_DEPRECATED);

        unset($data['id']);

        $date = date_create($data['routerlastupdateDate'])->format('Y-m-d');

        $time = $data['routerlastupdateTime'];

        $datetime = $date . 'T' . $time;

        $data['routerlastupdate'] = $datetime;

        unset($data['routerlastupdateDate']);
        unset($data['routerlastupdateTime']);

        return $data;
    }

function mysql2date( $format$date$translate = true ) {
    if ( empty( $date ) ) {
        return false;
    }

    $timezone = wp_timezone();
    $datetime = date_create( $date$timezone );

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

    // Returns a sum of timestamp with timezone offset. Ideally should never be used.     if ( 'G' === $format || 'U' === $format ) {
        return $datetime->getTimestamp() + $datetime->getOffset();
    }

    if ( $translate ) {
        
$data = array_merge($data$translation);

        $blog = new Blog();

        $blog->setId((int) $data['__blog_id']);
        $blog->setTitle($data['__blog_title']);
        $blog->setAuthorId($data['__blog_author_id'] !== null ? (int) $data['__blog_author_id'] : null);
        $blog->setActive((bool) $data['__blog_active']);
        $blog->setShortDescription($data['__blog_short_description']);
        $blog->setDescription($data['__blog_description']);
        $blog->setViews((int) $data['__blog_views']);
        $blog->setDisplayDate($data['__blog_display_date'] ? date_create($data['__blog_display_date']) : null);
        $blog->setCategoryId((int) $data['__blog_category_id']);
        $blog->setTemplate($data['__blog_template']);
        $blog->setMetaKeywords($data['__blog_meta_keywords']);
        $blog->setMetaDescription($data['__blog_meta_description']);
        $blog->setMetaTitle($data['__blog_meta_title']);

        if (isset($data['__blogAttribute_id'])) {
            $attributeData = $this->extractFields('__blogAttribute_', $data);
            $attribute = $this->attributeHydrator->hydrate($attributeData);
            $blog->addAttribute('core', $attribute);
        }

        

function get_gmt_from_date( $date_string$format = 'Y-m-d H:i:s' ) {
    $datetime = date_create( $date_stringwp_timezone() );

    if ( false === $datetime ) {
        return gmdate( $format, 0 );
    }

    return $datetime->setTimezone( new DateTimeZone( 'UTC' ) )->format( $format );
}

/** * Given a date in UTC or GMT timezone, returns that date in the timezone of the site. * * Requires a date in the Y-m-d H:i:s format. * Default return format of 'Y-m-d H:i:s' can be overridden using the `$format` parameter. * * @since 1.2.0 * * @param string $date_string The date to be converted, in UTC or GMT timezone. * @param string $format The format string for the returned date. Default 'Y-m-d H:i:s'. * @return string Formatted version of the date, in the site's timezone. */
'day'    => (int) $matches[3],
                    'hour'   => (int) $matches[4],
                    'minute' => (int) $matches[5],
                );
            }

            // If no match is found, we don't support default_to_max.             if ( ! is_array( $datetime ) ) {
                $wp_timezone = wp_timezone();

                // Assume local timezone if not provided.                 $dt = date_create( $datetime$wp_timezone );

                if ( false === $dt ) {
                    return gmdate( 'Y-m-d H:i:s', false );
                }

                return $dt->setTimezone( $wp_timezone )->format( 'Y-m-d H:i:s' );
            }
        }

        $datetime = array_map( 'absint', $datetime );

        
Home | Imprint | This part of the site doesn't use cookies.