Smarty Internal Date function html_select_date () Usage example analysis, select function usage _php Tutorial

Source: Internet
Author: User

Smarty Internal Date function html_select_date () Usage example analysis, select function usage


This example describes the use of the Smarty internal date function html_select_date (). Share to everyone for your reference. Specific as follows:

Main properties:

Prefix//string type default prefix named "Date_"
The Start_year//string type implicitly believes that the current year can still be represented in the (+/-n) mode, such as start_year= " -10" option starting from 1998
End_year//string Type default above available (+/-N) mode is represented as end_year= "+5" option to 2013
Field_order//string Type Default MDY is the emission of select in the Order of the month-day year
Month_format//string Type Default%b is displayed as January, February, etc.%b format shows the first three letters of the month in abbreviated form
%M format for digital display month
Day_format//string Type Default%02d number represents from 01~31 and is not associated with the month%b format is rarely used for binary display formats

Other properties:

Display_days//boolean Type Controls whether day's select is displayed
Display_months//boolean Type Controls whether the select for month is displayed
Display_years//boolean Type Controls whether the select of year is displayed
Year_as_text//boolean Type true display as text type year false display as drop-down menu type
Reverse_years//boolean Type True if the year is in reverse order
Year_size//string Type value is drop-down menu-type output 0 or 1 o'clock for the up and down arrows in cases greater than 1
Month_size//Ibid.
Day_size//Ibid.

Examples are as follows:

Copy the code as follows: {html_select_date prefix= "StartDate" time= $time start_year= "-5" end_year= "+1" Display_days=false}

OUTPUT: (Current year is 2000)

JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember1995199619971998199920002001

Other properties, please debug yourself. The disadvantage of this date processing function is that day is not associated with month, so it is better to use JS processing

The function of which JS displays day can be defined as follows:

function Showdays (year,month) {var day= "day", if (month.value==0) {document.getElementById (day). Length=1; return;} else{if (month.value==1| | month.value==3| | month.value==5| | month.value==7| | month.value==8| |month.value==10| | month.value==12) {   document.getElementById (day). Length=1;   CreateList (1,32,day);   Return }else if (month.value==2) {if (year.value%4==0&&year.value%100!=0| | year.value%400==0) {document.getElementById (day). Length=1; CreateList (1,30,day); return;} else{document.getElementById (day). Length=1; CreateList (1,29,day); return;}} else{document.getElementById (day). Length=1; CreateList (1,31,day); return;}}

I hope this article is helpful to everyone's smarty-based PHP programming.

http://www.bkjia.com/PHPjc/1028975.html www.bkjia.com true http://www.bkjia.com/PHPjc/1028975.html techarticle smarty Internal Date function html_select_date () Usage instance analysis, select function Usage This example describes the use of the Smarty internal date function html_select_date (). Share for everyone to join us ...

  • 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.