Home > php教程 > php手册 > body text

WordPress the_time函数时间格式汇总

WBOY
Release: 2016-06-06 20:09:39
Original
949 people have browsed it

WordPress中输出日期、时间可以用: ?php the_time('Y年m月d日 H:i'); ? 。 让我一起看一下WordPress函数 the_time() 里面参数的具体含义。 日期(年-月-日)的含义: ?php the_time('Y-m-j'); ? 输出:2007-02-6 ?php the_time('y-n-j');? ? 输出:07-2-6

WordPress中输出日期、时间可以用:<?php the_time('Y年m月d日 H:i'); ?>

让我一起看一下WordPress函数the_time()里面参数的具体含义。

日期(年-月-日)的含义:

输出:2007-02-6

输出:07-2-6

大写Y表示年四位数字,而小写y表示年的两位数字;

小写m表示月份的数字(带前导),而小写n则表示不带前导的月份数字。

输出:2007-Feb-6

输出:2007-02-06

大写M表示月份的3个缩写字符,而小写m则表示月份的数字(带前导0);

没有大写的J,只有小写j表示月份的日期,无前导o;若需要月份带前导则使用小写d。

输出:2007-February-6th

大写M表示月份的3个缩写字符,而大写F表示月份的英文全写。(没有小写f)

大写S表示日期的后缀,比如“st”、“nd”、“rd”和“th”,具体看日期数字为何。

小结:

表示年可以用大写的Y和小写y;

表示月可以用大写F、大写M、小写m和小写n(分别表示字符和数字的两种方式);

表示日可以用小写d和小写j,大写S表示日期的后缀。

下面主要说一下时间的参数的含义(时:分:秒):

默认情况下,PHP解释显示的时间为“格林威治标准时间”,与我们本地的时间相差8个小时。

输出:5:56:57 am

输出:05:56:57 AM

小写g表示12小时制,无前导0,而小写h则表示有前导0的12小时制。

当使用12小时制时需要表明上下午,小写a表示小写的“am”和“pm”,大写A表示大写的“AM”和“PM”。

输出:8:02:26

输出:08:02:26

大写G表示24小时制的小时数,但是不带前导的;使用大写的H表示带前导的24小时制小时数

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!