我在wordpress中的日期函数有问题。
我试图在某些页面上获得不同的发布日期格式,并且一直尝试"the_date()“、"the_time()”和"echo get_the_date()“。他们的行为都是一样的。
当我输入正确的日期格式(例如the_time() )时,它们会输出正确的日期格式。输出是我在wordpress设置中设置的格式,正如预期的那样。
问题是,当我尝试用ex: the_time('d')格式化输出时,输出是"d“,或者回显get_the_time('F,Y');输出是‘F,Y’。
我忘了提到代码在“循环”中
这是我的page.php
<?php get_header();?>
<?php get_sidebar('subnav');?>
<section class="main-content2" id="page">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title();?></h1>
<?php the_content();?>
<footer class="meta">Publicerades den <?php echo get_the_date('d');?></footer>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</section>
<?php get_footer();?> 我不明白问题出在哪里,请帮帮忙!)
发布于 2013-07-27 12:09:26
当使用日期函数时,重新命令使用安装的日期格式或时间格式:
get_option('time_format');
get_option('date_format');这允许您获取当前安装的日期格式或时间格式。
发布于 2015-02-25 19:08:28

您需要选择“使用模拟日期函数”,而不是“使用strftime而不是日期”。
发布于 2015-02-25 20:45:39
the_time不能工作的主要原因是您正在the_time中输入日期格式(05/01/2015),这是专为time (5:00 pm)而设的。
https://wordpress.stackexchange.com/questions/108008
复制相似问题