滑块的日期和时间 [英] Slider for date and time

查看:71
本文介绍了滑块的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我在jquery中有滑块的问题。我需要为日期准备滑块,但我不知道它是如何制作的。在我的代码下面。有人知道如何在格式上更改我的滑块的日期和时间(YYYY-MM-DD h:mm)。



Hello. I have problem with slider in jquery. I need prepare slider for date an time but i don't know how it make. Below my code. Someone have idea how change my slider for date and time on format (YYYY-MM-DD h:mm) .

var minVal, maxVal, infoMin, infoMax, data1, data2;
           data1 = '2016-02-10 10:36'
           data2 = '2016-02-11 13:47'
           minVal = '10:36';
          maxVal = '13:47';
          minVal = parseInt(minVal.substring(0, 2) * 60) + parseInt(minVal.substring(3, 5))
          maxVal = parseInt(maxVal.substring(0, 2) * 60) + parseInt(maxVal.substring(3, 5))

           jQuery(function () {
              jQuery('#slider-time').slider({
                   range: true,
                       min: parseInt(minVal),
                       max: parseInt(maxVal),
                       step: 1,
                       values: [minVal,maxVal],
                       slide: function (event, ui) {

                       var hours1 = Math.floor((ui.values[0]) / 60) ;
                            var minutes1 = (ui.values[0] - (hours1 * 60));

                            if (hours1 == 0)
                           { hours1 = '0' + hours1; }
                           else if (hours1<10)
                           {hours1= '0' + hours1;}
                            if (minutes1 == 0)
                            { minutes1 = '00'; }
                            else if (minutes1 < 10)
                            { minutes1 = '0' + minutes1;}

                         var hours2 = Math.floor(ui.values[1] / 60) ;
                      var minutes2 = ui.values[1] - (hours2 * 60);

                        if (hours2 == 0)
                        { hours2 = '0' + hours2; }
                        else if (hours2 < 10)
                        { hours2 = '0' + hours2; }
                        if (minutes2 == 0)
                        { minutes2 = '00'; }
                       else if (minutes2 < 10)
                        { minutes2 = '0' + minutes2; }
                         if (minutes2 == 0)
                          minutes2 = '00';

                      $('#tb3').val(hours1 + ':' + minutes1+':00')
                      $('#tb4').val(hours2 + ':' + minutes2 + ':00')
                   }
               });
           });







<div id="slider-time"></div>
<asp:TextBox ID="tb3" runat="server"></asp:TextBox>
<asp:TextBox ID="tb4" runat="server"></asp:TextBox>





我尝试了什么:



在一个小时之前添加,但我无法一起更改日期和时间。



What I have tried:

Added before an hour date but i can't change date and time together.

推荐答案

' #tb3')。val(hours1 + ' :' + minutes1 + ' :00'
('#tb3').val(hours1 + ':' + minutes1+':00')


' #tb4')。val(hours2 + ' :' + minutes2 + ' :00'
}
});
});
('#tb4').val(hours2 + ':' + minutes2 + ':00') } }); });







<div id="slider-time"></div>
<asp:TextBox ID="tb3" runat="server"></asp:TextBox>
<asp:TextBox ID="tb4" runat="server"></asp:TextBox>





我尝试了什么:



在一个小时之前添加,但我无法一起更改日期和时间。



What I have tried:

Added before an hour date but i can't change date and time together.


你为什么不去约会时间选择器...... ???
Why don't you go for date time picker ... ???


这篇关于滑块的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆