TimePicker Comparison with current time With specific timezone RRS feed

  • Question

  • I have to restrict user that after 5:00 PM button will be disabled .

    I achieve that, but user s able to change timezone from his laptop and select another timezone where previpus times comes an able to submit the request.

    I use this code for get current time 

    var day = curTime.getDay();
    curTime = parseInt(curTime.getHours() + "" + ("0" + curTime.getMinutes()).substr(-2) + "" + ("0" + curTime.getSeconds()).substr(-2));

    and also this :

     var CrntTime = d.getTime();

    but its taking system timezone...I want specif time zone ...

    my time zone is (UTC+05:30) Chennai,Kolkata,,Mumbai,New Delhi

    Shiv Sharma

    Friday, July 3, 2020 5:21 PM

All replies

  • Hi,

    Use moment.tz to convert the time to specific time zone.

    Sample script for your reference.

     <script type="text/javascript">
            $(function () {            
                    defaultDate: new Date(),
                    ignoreReadonly: true,
                    inline: true,
                    sideBySide: true,
                    format: 'MM/DD/YYYY hh:ss'
                }).on("dp.change", function (e) {
                    var localKolkata = moment.tz(e.date, "Asia/Kolkata");
                    //hour only
                    var localTime = moment(localKolkata.format('MM/DD/YYYY hh:mm:ss')).hour();

    Tip: for JavaScript only requirements/issues, I would suggest you post in JavaScript related forum(such as https://stackoverflow.com/questions/tagged/momentjs), so the community members who read the forum regularly can either share their knowledge.

    Best Regards,


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, July 6, 2020 4:48 AM
  • Please update in my code:

    $(function () {
                        format: 'LT'
                    }).on('dp.change', function (e) {
                     var varDrpDate= $("#txtdrpDate").val();
      var d = new Date();
                 var date = new Date().toLocaleDateString(); 
                   var CurrentDate = new Date();
                 var date2 = new Date($('#txtdrpDate').val());
                 var NewDrpDate=new Date(varDrpDate).toLocaleDateString();
                      var format = 'hh:mm:ss'
                        var tmpTime = moment();                                                
                        var time = moment(new Date(e.date)),
                            beforeTime = moment(tmpTime.add(2, 'hours'), format),
                            afterTime = moment(tmpTime.add(4, 'hours'), format);
                      if(ADCity!="Noida" && CurrentDate >= date2 )
                        if (time.isBetween(beforeTime, afterTime)) {
                            console.log('is between');
                        } else {

    Shiv Sharma

    Friday, July 10, 2020 8:26 AM
  • I search a lot but unable to find solution of my problem, 

    Requirement: To Get Current Date & Time.

    Issue: While changing Date or timezone or time in Date time setting of the laptop its start fetching local timezone.

    I want UTC +05:30 ie. Asia/Kolkata time Zone

    Note : It should work in IE also.

    Shiv Sharma

    Friday, July 17, 2020 10:27 AM