JS judges the size of two times

Source: Internet
Author: User

JS judges the size of two times

Function checkdate ()
{

// Get the date value and convert it to the date format. Replace (//-/g, "//") converts the date to the Growth date format based on the validation expression.

// Judge again.
VaR sdate = new date (document. getelementbyid ("txtstart"). value. Replace (//-/g ,"//"));
VaR edate = new date (document. getelementbyid ("txtend"). value. Replace (//-/g ,"//"));
If (sdate> edate)
{
Alert ("the end date cannot be earlier than the start date ");
Return false;
}
Return true;
}

 

 

Take the two time intervals

Timespan ts1 = new timespan (time1.ticks );

// Timespan ts2 = new timespan (ftime2.ticks );

// Timespan Ts = ts1.subtract (ts2). duration ();
// If (Int. parse (TS. Days. tostring ()> 0)
//{
// Datediff + = ts. Days. tostring () + "day ";
//}
// If (Int. parse (TS. Hours. tostring ()> 0)
//{
// Datediff + = ts. Hours. tostring () + "Hour ";
//}
// If (Int. parse (TS. Minutes. tostring ()> 0)
//{
// Datediff + = ts. Minutes. tostring () + "Minute ";
//}

 

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.