Introduction of thinkphp Time format operation

Source: Internet
Author: User

Number 24th began to learn thinkphp, today can not wait to practice the hand, but for thinkphp or a smattering of me, the start is more difficult, the unit inside just came to a corporate website, take thinkphp to practicing it, today take thinkphp do a corporate site, In the output time, but output the PHP timestamp, that is, a string of numbers, is obviously to be the time format, in PHP as long as a class can be, but a thinkphp template inside do not know how to output, had to query the Thinkphp official website, the original is the output label , change the time label to normal output time.

Scenario One (Action Controller):

As formatted in native PHP code, use the DATE function:


$time = Date ("y-m-d", $time)

Scenario two (template):


{$time |date= ' y-m-d ', ###}

As shown below:

{$wz [' add_time ']|date= ' y-m-d ', ###}

{$wz [' Add_time ']} has a value of 1372468992 and the time shown is 2013-01-24

The correct value is: 2013-06-29

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.