• Resolved fibbu

    (@fibbu)


    Hello;

    Thank you for this nice plugin.
    Can we calculate the time difference between countries? The user will select the country with a dropdown menu.
    Example : Option 1 chose USA / Alaska
    Option 2 chose France

    In conclusion;
    It will write the USA / Alaska time 24/07/2023 14:50
    It will write the time of France 24/07/2023 15:50
    It will write the time difference as 1 hour as the result.
    Thanks.

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

    (@codepeople)

    Hello @fibbu,

    Thank you very much for using our plugin.

    Yes. You can calculate the time difference, but the solution depends on your form structure.

    For example, if you have two date/time fields in the form with only time components to allow the users to enter them (fieldname1 and fieldname2). Insert a calculated field in the form, and enter an equation similar to the following one:

    
    (function(){
    var d = DATEDIFF(fieldname1, fieldname2, 'dd/mm/yyyy hh:ii', 'h');
    return d['hours']+' hours and '+d['minutes']+' minutes';
    })()

    If you have only two dropdown fields with places, I recommend entering the places’ names as their choices’ texts and the time zones as their values (like France 1 and Alaska -9). The equation would be:

    ABS(fieldname1-fieldname2)

    Best regards.

    Thread Starter fibbu

    (@fibbu)

    So how do we get the current time of the country? I made a dropdown menu. Argentine (A) and Brazil (B). In summary, how can we apply the time zones of all countries?
    Your calculation method makes sense yes.

    Thread Starter fibbu

    (@fibbu)

    Plugin Author codepeople

    (@codepeople)

    Hello @fibbu

    You must enter the time zones in the dropdown fields.

    Each choice in the DropDown fields contains two input boxes for the choice’s text and value, respectively. You must enter the time zones as the choices’ values and country names as the choices’ texts.

    You must determine the current time zone to calculate the date/time in the countries selected in the dropdown fields (fieldname1, fieldname2). The equation would be similar to:

    
    (function(){
    var current_timezone = new Date().getTimezoneOffset()/(-60),
    result = NOW();
    
    result.setHours(result.getHours()-current_timezone+fieldname1);
    result.setHours(result.getHours()+fieldname2);
    
    return GETDATETIMESTRING(result, 'dd/mm/yyyy hh:ii a');
    })()

    Please, note the plugin support does not cover the implementation of the users’ projects. If you need a custom coding service to implement your project, please, contact us directly via the plugin website Contact Us

    Best regards.

    Thread Starter fibbu

    (@fibbu)

    Firstly, thank you. I made the clocks of the countries with the method you said. Only one minor problem remained.

    jQuery(‘.criter-one’).html(‘Saat Fark?: ‘);

    (‘Saat Fark?: ‘); How to print the selected Country name in Dropdown?
    Thanks

    • This reply was modified 1 year, 4 months ago by fibbu.
    Plugin Author codepeople

    (@codepeople)

    Hello @fibbu

    In the DropDown field, you must tick the “Choice text” option for the “Value to submit” attribute (this modification does not affect the equations that remain using the choices’ values).

    Assuming the dropdown field is the fieldname1, you can access the value of the choice selected from the equation as always, fieldname1, and its text by using the |v modifier fieldname1|v

    If you have any other questions about coding, please, indicate the URL to the page that contains the form to check your code in action.

    Best regards.

    Thread Starter fibbu

    (@fibbu)

    fieldname my fields are 29 and 30
    to print them on the screen.
    jQuery(‘.criter-one’).html (‘fieldname29|v ‘);
    do i need to do?

    Can you show me how to write a small example in this code?
    I have no other questions. thanks

    Thread Starter fibbu

    (@fibbu)

    yes i did it thanks superrr

    Plugin Author codepeople

    (@codepeople)

    Hello @fibbu

    The code depends on the place you use it.

    If the code is part of an equation, the correct would be:

    jQuery('.criter-one').html(fieldname29|v);

    Without quotes in the around the field’s name.

    If the code is called from a different context, like the onclick event of a button, it would be:

    jQuery('.criter-one').html(getField('fieldname29').val(true, true));

    If the tag with the criter-one class name is inside the form structure, like an “HTML Content” field, you would not need any of previous code, only to use data-cff-field attribute in the tag. Ex.

    
    <span class="criter-one" data-cff-field="fieldname29"></span>

    Best regards.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Time difference between countries’ is closed to new replies.