formatrecovery php Smarty date_format [format time Date]

Source: Internet
Author: User
Tags iso 8601 month name
Example 5-8. date_format[Date format]
index.php:

Copy the Code code as follows:


$smarty = new Smarty;
$smarty->assign (' Yesterday ', Strtotime ('-1 day '));
$smarty->display (' Index.tpl ');
INDEX.TPL:
{$smarty. Now|date_format}
{$smarty. Now|date_format: "%A,%B%e,%Y"}
{$smarty. Now|date_format: "%h:%m:%s"}
{$yesterday |date_format}
{$yesterday |date_format: "%A,%B%e,%Y"}
{$yesterday |date_format: "%h:%m:%s"}


OUTPUT:

Copy the Code code as follows:


Feb 6, 2001
Tuesday, February 6, 2001
: 33:00
Feb 5, 2001
Monday, February 5, 2001
: 33:00


Example 5-9. Date_format conversion specifiers[Date Conversion description]

Copy the Code code as follows:


%a-abbreviated weekday name According to the current locale
(output "Week" abbreviation format according to local format)
%a-full weekday name According to the current locale
(output "Week" full format according to local format)
%b-abbreviated month name According to the current locale
(output "month" abbreviation format according to local format)
%b-full month name According to the current locale
(output "month" full format according to local format)
%c-preferred Date and time representation for the current locale
%c-century Number (the year divided by and truncated to an integer, Range xx to 99)
%d-day of the month as a decimal number (range xx to 31)
%d-same as%m/%d/%y
%e-day of the month as a decimal number, a single digit was preceded by a
Space (range 1 to 31)
%g-week-based year within century [00,99]
%g-week-based year, including the century [0000,9999]
%h-same as%b
%h-hour as a decimal number using a 24-hour clock (range xx to 23)
%i-hour as a decimal number using a 12-hour clock (range 12)
%j-day of the year as a decimal number (range 001 to 366)
%k-hour (24-hour clock) single digits is preceded by a blank. (range 0 to 23)
%l-hour as a decimal number using a 12-hour clock, single digits preceeded by
A space (range 1 to 12)
%m-month as a decimal number (range 12)
%m-minute as a decimal number
%n-newline character
%p-either ' am ' or ' PM ' according to the given time value, or the corresponding strings for the current locale
%r-time in a.m. and P.M. notation
%r-time in hour notation
%s-second as a decimal number
%t-tab character
%t-current time, equal to%h:%m:%s
%u-weekday as a decimal number [1,7], with 1 representing Monday
%u-week number of the current year as a decimal number, starting with the first Sunday as the first day of the first wee K
%v-the ISO 8601:1988 Week number of the current year as a decimal number, range, where Week 1
Is the first week that have at least 4 days in the current year, and with Monday as the first day of the week.
%w-day of the week as a decimal, Sunday being 0
%w-week number of the current year as a decimal number, starting with the first Monday as the first day of the first wee K
%x-preferred date representation for the current locale without the time
%x-preferred time representation for the current locale without the date
%y-year as a decimal number without a century (range xx to 99)
%y-year as a decimal number including the century
%z-time zone or name or abbreviation
Percent-a literal '% ' character


Programmers Note:date_format is essentially a wrapper to PHP ' s strftime ()
function. Conversion specifiers Available depending
On your system ' s strftime () function where PHP is compiled. Check your
System ' s manpage for a full list of valid specifiers.
Programmer's tip: Date_format is essentially a wrapper for PHP's strftime () function.
When PHP is compiled, you can rely more or less on the system's Strftime () to convert valid delimiters.
You can view the full table of valid delimiters for the system manual.

The above describes the formatrecovery php Smarty date_format [format time Date], including formatrecovery aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.