rest_get_date_with_gmt example

 else {
            $prepared_comment['comment_author_IP'] = '127.0.0.1';
        }

        if ( ! empty( $request['author_user_agent'] ) ) {
            $prepared_comment['comment_agent'] = $request['author_user_agent'];
        } elseif ( $request->get_header( 'user_agent' ) ) {
            $prepared_comment['comment_agent'] = $request->get_header( 'user_agent' );
        }

        if ( ! empty( $request['date'] ) ) {
            $date_data = rest_get_date_with_gmt( $request['date'] );

            if ( ! empty( $date_data ) ) {
                list( $prepared_comment['comment_date']$prepared_comment['comment_date_gmt'] ) = $date_data;
            }
        } elseif ( ! empty( $request['date_gmt'] ) ) {
            $date_data = rest_get_date_with_gmt( $request['date_gmt'], true );

            if ( ! empty( $date_data ) ) {
                list( $prepared_comment['comment_date']$prepared_comment['comment_date_gmt'] ) = $date_data;
            }
        }

        
if ( is_wp_error( $status ) ) {
                return $status;
            }

            $prepared_post->post_status = $status;
        }

        // Post date.         if ( ! empty( $schema['properties']['date'] ) && ! empty( $request['date'] ) ) {
            $current_date = isset( $prepared_post->ID ) ? get_post( $prepared_post->ID )->post_date : false;
            $date_data    = rest_get_date_with_gmt( $request['date'] );

            if ( ! empty( $date_data ) && $current_date !== $date_data[0] ) {
                list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
                $prepared_post->edit_date                                        = true;
            }
        } elseif ( ! empty( $schema['properties']['date_gmt'] ) && ! empty( $request['date_gmt'] ) ) {
            $current_date = isset( $prepared_post->ID ) ? get_post( $prepared_post->ID )->post_date_gmt : false;
            $date_data    = rest_get_date_with_gmt( $request['date_gmt'], true );

            if ( ! empty( $date_data ) && $current_date !== $date_data[1] ) {
                list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
                
Home | Imprint | This part of the site doesn't use cookies.