Date 日期差异和与javascript中值的匹配

Date 日期差异和与javascript中值的匹配,date,duration,Date,Duration,嗨,我有下拉列表,值为一年、两年……等等。。好啊此外,我有两个ajax文本框与日历延长。如果下拉选择值为一年,并且两个文本框值之间的持续时间表示日期不匹配,我想弹出警报消息。明白我的意思吗?请帮帮我。 如何在javascript中获取此场景?? Algorithm : 1.Get the both date from the text box. 2. The find the epcoch time for each date. // 3. subtract the both dates. 4.

嗨,我有下拉列表,值为一年、两年……等等。。好啊此外,我有两个ajax文本框与日历延长。如果下拉选择值为一年,并且两个文本框值之间的持续时间表示日期不匹配,我想弹出警报消息。明白我的意思吗?请帮帮我。 如何在javascript中获取此场景??

Algorithm : 1.Get the both date from the text box. 2. The find the epcoch time for each date. // 3. subtract the both dates. 4. subtract_result = 365*24*60*60 // Finding the 1 year timestamp values 5. So, it the difference exceed than above calculation , you could sure that the date is mis matching.

Javascript:
    // This is for first date
    first = new Date(2010, 03, 08, 15, 30, 10); // Get the first date epoch object
    document.write((first.getTime())/1000); // get the actual epoch values
    second = new Date(2012, 03, 08, 15, 30, 10); // Get the first date epoch object
    document.write((second.getTime())/1000); // get the actual epoch values
    diff= second - first ;
    one_day_epoch = 24*60*60 ;  // calculating one epoch
    if ( diff/ one_day_epoch > 365 ) // check , is it exceei
    {
    alert( 'date is exceeding one year');
    }