0

嗨,我正在使用 wordpress 处理高级自定义字段,我正在尝试修复要显示的日期:24/01/201 而不是 01/24/2013

我一直在查看 ACF 站点,但我似乎无法找到它为什么这样做。

请找到我的代码:)

<?php
 // start query
                       $query_args = array(

                           // number of featured items to show
                           'posts_per_page' => '-1',
                           'post_type' => 'product',


                       );

                       $args = array(
                            'meta_key' => 'time_&_date',
                            'orderby' => 'meta_value_num',
                            'order' => 'DESC'
                        );

                        $the_query = new WP_Query( $args );

                        while ( $the_query->have_posts() ) : $the_query->the_post();

                            $date = DateTime::createFromFormat('Ymd', get_field('time_&_date'));
                            echo $date->format('M d, Y');
                        endwhile;



                       // start loop
                       $wp_query = new WP_Query($query_args);
                       if ($wp_query->have_posts()) {
                       echo '<ul class="eventslist">';


                        echo '</br>';
                        echo '</br>';
                           // start while
                           while($wp_query->have_posts()) : $wp_query->the_post();
                           $_product = new jigoshop_product(get_the_ID());
                           echo '<li>';
                               // Event container
                               echo '<a href="'.get_permalink().'">';

                              // Event title
                              echo '<div class="loop_title lightlinksnounderline"> <span>&bull;</span>' . the_title('','',false);


                              echo '</a>';
                              echo '</div>';

                              echo '<h3 class="field_title_loop">Date &amp Time: '; the_field('time_&_date');


                                    echo '</h3>';
                                     echo '<div class="cart_button">' ; do_action('jigoshop_after_shop_loop_item', $post, $_product );
                                        echo '</div>';

                           echo '</li>';
                           echo '<div class="price_cart">' ; do_action('jigoshop_after_shop_loop_item_title', $post, $_product);
                                echo '</div>';
                           echo '</br>';



                            echo '<div class="cart_line">';
                                     echo '</div>';


                           // end while
                           endwhile;
                       echo '</ul>';

                       // end loop
                       // reset query
                       wp_reset_query();
                       }

    ?>  
4

1 回答 1

0

你的 $date->format 不应该是 (d MY) 吗?

于 2013-02-20T13:23:48.080 回答