Convert to a date input control, supports FF

Source: Internet
Author: User

<HTML>
<Head>
<Title> date selector </title>
<SCRIPT type = "text/JavaScript">
/**
* Return date
* @ Param d the delimiter
* @ Param p the pattern of your date
* @ Author xinge (modify)
*/
String. Prototype. todate = function (X, p ){
If (x = NULL) x = "-";
If (P = NULL) P = "ymd ";
VaR A = This. Split (X );
Var y = parseint (A [P. indexof ("Y")]);
// Remember to change this next century
If (Y. tostring (). Length <= 2) y ++ = 2000;
If (isnan (y) y = new date (). getfullyear ();
VaR M = parseint (A [P. indexof ("M")])-1;
VaR d = parseint (A [P. indexof ("D")]);
If (isnan (D) d = 1;
Return new date (Y, M, d );
}

/**
* Format the date
* @ Param d the delimiter
* @ Param p the pattern of your date
* @ Author xinge (modify)
*/
Date. Prototype. format = function (style ){
VaR o = {
"M +": This. getmonth () + 1, // month
"D +": This. getdate (), // day
"H +": This. gethours (), // hour
"M +": This. getminutes (), // minute
"S +": This. getseconds (), // second
"W +": "five or six days, January 1, 1234". charat (this. getday (), // week
"Q +": Math. Floor (this. getmonth () + 3)/3), // quarter
"S": This. getmilliseconds () // millisecond
}
If (/(Y +)/. Test (style )){
Style = style. Replace (Regexp. $1,
(This. getfullyear () + ""). substr (4-Regexp. $1. Length ));
}
For (var k in O ){
If (New Regexp ("(" + K + ")"). Test (style )){
Style = style. Replace (Regexp. $1,
Regexp. $1. Length = 1? O [k]:
("00" + O [k]). substr ("" + O [k]). Length ));
}
}
Return style;
};

/**
* Calendar
* @ Param beginyear 1990
* @ Param endyear

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.