• Resolved cattivodes

    (@cattivodes)


    I have a user input field for time. I’m trying to calculate if the time the user entered is later than 8pm. However, because your code includes the date and time together, my code would have to be different for each day.

    For example, this code works fine but ONLY for this specific day of the year:
    Sept 6, 2019

    (function(){

    if(fieldname38 > 435504) return “YES”;

    if(fieldname38 <= 435504) return “NO”;

    })();

    how would I make this code work for any inputed day of the year?
    thanks much!

    Fieldname38=
    (function(){
    var date1 = new Date(fieldname2*86400000),
    s = ABS(date1)/1000,
    h = FLOOR(s/3600);
    m = (FLOOR((s%3600)/60)/60);
    return h+m;
    })()

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @cattivodes

    The process is very simple:

    
    (function(){
    var d = new Date(fieldname2*86400000), h = d.getHours(), m = d.getMinutes();
    return h+' hours and '+m+' minutes';
    })()
    

    and if you want to get the time in 12 hours format:

    
    (function(){
    var d = new Date(fieldname2*86400000), h = d.getHours(), m = d.getMinutes(), ampm='am';
    if(12<h)
    {
    h -= 12;
    ampm = 'pm';
    }
    
    return h+' hours and '+m+' minutes '+ampm;
    })()
    

    You don’t need to know the day of the year to determine the time.

    Best regards.

    Thread Starter cattivodes

    (@cattivodes)

    awesome. Thank you

    Thread Starter cattivodes

    (@cattivodes)

    another question:
    On my form, I have a field to enter a Start-Time and one to enter a Finish-Time.
    Within that entered time-frame, I want to be able to count the number of hours between 8pm and 1am and separately the number of hours between 1am and 6am.

    For example: user enters Start-Time: 5pm and Finish-Time: 3am
    Within that range there are 5 Hours in the 8pm-1am TimeSlot
    and there are 2 Hours in the 1am-6am Timeslot.

    Is there a way to calculate these? I’m driving myself crazy trying to figure this out. Thanks much!

    Plugin Author codepeople

    (@codepeople)

    Hello @cattivodes

    I’m sorry, but as you can understand, it’s not possible for me to implement all user projects as part of the support service.

    For pro or commercial product support or service please contact us directly on our site. This includes any pre-sales topics as well.

    Commercial products or services are not supported in these forums. We will happily answer this and any other questions you can have on our own site.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Time Calculations without date’ is closed to new replies.