Help with Javascript rounded times

Hello

I was wondering if someone can help me.

I have this code which doesn't seem to work. It is intended to round time only if the time by 1 minute.

For example. If the time is listed as: 21:08 then it should turn up to 22:00.

If the time is listed as: 21:00, then she must stay the same.

The problem I have is that if the time is listed as: 21:00, and then is rounded to 22:00. but should remain at 21:00

function roundUptoHour ($timestring) {}

$datetime = new DateTime ($timestring);

return $datetime-> change (' next time ' ")-> format('H').': 0 0';

}

format('H').': 0 0';
}   

function roundUptoHour ($timestring) {
        $datetime = new DateTime ($timestring);
        } $datetime-> modify ('-1 minutes');
        return $datetime-> modify ('next hour')-> format('H').': 0 0';
}   

function elapsedHours ($strStart, $strEnd) {
        $dteStart = new DateTime (roundDowntoHour ($strStart));
        } $dteEnd = new DateTime (roundUptoHour ($strEnd));
        $dteDiff = $dteStart-> diff ($dteEnd);
        {if ($dteStart > $dteEnd) {
                        return 24 - $dteDiff-> Format ("hour");
        } else {
                        return $dteDiff-> Format ("hour");
        }
}  

$timestart = "16:00";
$timeend = "22:00";
$hourcost = 10;  

$totalhours = elapsedHours ($timestart, $timeend);
$timestartrounded = roundDowntoHour ($timestart);
$timeendrounded = roundUptoHour ($timeend);  

echo "hours elapsed:". $totalhours;
echo"
time start: ". $timestart." Rounded to:(".$timestartrounded.") "; " echo"
end time: ". $timeend." Rounded to:(".$timeendrounded.") "; " $timestart = "16:00"; $timeend = "22:01"; $hourcost = 10; $totalhours = elapsedHours ($timestart, $timeend); $timestartrounded = roundDowntoHour ($timestart); $timeendrounded = roundUptoHour ($timeend); echo"

Tags: Dreamweaver

Similar Questions

  • Clicking on the tab help for help with photoshop first time get in "photoshop online help could not be displayed because you are not connected to internet" but I'm connected to the internet?

    Dear all

    I need help with the following problem:

    Clicking on the tab help for help with photoshop first time get in "photoshop online help could not be displayed because you are not connected to internet" but I'm connected to the internet.

    Appreaciate help on this problem.

    MSD

    I find it easier and faster to use just this link, which goes to the same place as aid > online help for Photoshop:

    Using Photoshop | Photoshop help

    To bookmark so that you can find.

  • Please help with reset the time lock

    We have problems with our computer to lock if we are online, etc.  We need to connect back with our password to see what we were reading.  If the mouse is still for a few minutes, the computer will automatically lock the computer mode.  Can someone tell me how to set this time around so that it does not lock the computer after a minute.

    Thank you!!

    Hi jomabe,

    Thanks for posting of answers.microsoft.com with respect to this application.

    According to the information provided, it can be either parameter must be changed or the option of power setting could be revised in order to help you with this problem.

    For a change of setting screen saver, click on empty place on the desktop and select PERSONALIZE / screen saver - check if the waiting period is set for a time relevant to your operation or if it needs to be revised.  In addition, if the Logon Screen summary view is checked, it will ask login during the resumption of the activation of the screen saver.

    Another area that may be the result of what is living could be in the power Plan options.  To check if the power management options contribute to the problem, follow these steps to customize a diet plan to check whether components that can be going to sleep can be adjusted to your needs.

    How to customize a diet plan

    To customize a diet plan, follow these steps:

    1. Click Start
      type Power Options in the start search box, and then click Power Options in the list programs.
    2. Click on change settings for the plan under the plan.
    3. The parameters of change for the plan page, select the display settings and parameters of sleep that you want your computer to use, or click on change advanced power to change additional settings.
    4. Click OK, or click on save changes to save the changes.

      Ensure that the plan of the power that you want the computer to use is selected in the Power Options page.

    Pasted from http://support.microsoft.com/kb/935799>

    Make sure to consider change Advanced Power settings selected in the context of your current power plan to check if a network card, hard drive or other component can go to 'sleep '.

    Please let us know on this issue if it helps with the determination or help.

    Kind regards

    Debbie
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Need help with Javascript for Acrobat 9 Pro

    Hello

    I have created a PDF form in Adobe Acrobat 9 of Profession.  Not having not much experience with Javascript, I found this forum very helpful and have many examples of script used to other issues, I had.  I was hoping that someone could help me with the following script, I tried many variations, cannot operate.

    var ratio = this.getField("ratio").value
    concentration of var = this.getField("concentration").value
    var result = this.getField("result").value
    If (ratio.value > = 50.00)
    {result.value = 'PASS' ;}
    If (ratio.value".value > = 40.00)
    {result.value = 'PASS' ;}
    If ((concentration.value ==61) & & (ratio.value > = 49,25))
    {result.value = 'PASS' ;}
    If ((concentration.value ==61) & & (ratio.value > = 39.25))
    {result.value = 'PASS' ;}
    If ((concentration.value ==62) & & (ratio.value > = 48.50))
    {result.value = 'PASS' ;}
    If ((concentration.value ==62) & & (ratio.value > = 38.50))
    {result.value = 'PASS' ;}
    on the other
    {result.value = "FAIL" ;}

    It's just a piece of code, concentration values run from 61 to 99 and the value of the ratio varies for each value of the concentration, there is a high ratio and a low ratio.  The result of this field to complete the field of results with a SUCCESS or a FAILURE.  This isn't working... any help is greatly appreciated!

    If this script is attached to the Calculate of the "result" field event, if I understand correctly the logicm code should be something like:

    // Get a reference to the ratio field
    var ratio = this.getField("ratio");
    
    // Get a reference to the concentration field
    var concentration = this.getField("concentration"); 
    
    // Default
    var res = "FAIL";
    
    if (ratio.value >= 40.00) {
        res = 'PASS';
    }
    
    if ((concentration.value == 61) && (ratio.value >= 39.25)) {
        res = 'PASS';
    }
    
    if ((concentration.value == 62) && (ratio.value >= 38.50)) {
        res ='PASS';
    }
    
    // Set this field's value
    event.value = res;
    

    If the code is placed elsewhere, you must indicate the location.

  • Help with Javascript to populate a list

    Hello

    I'm doing a smart entry form for a singing competition.

    I have a page of classes to enter and I want folk to be able to check a box for which classes which wish to enter and this will a list of classes and class names on the entry form page.

    I used this code in the box.

    If (event.target.value! = "Off") {//If checkbox is checked

    this.getField("ClassN1").value = "own selection - under 8 years;

    }

    else this.getField("ClassN1").value = "";  Clear the text field if the check box is unchecked

    var solo =]

    for (var i = 1; i < = 7; i ++) {}

    var a = getField('ClassN'_+_i).value

    If (a) solo.push (a)

    getField('ClassName'_+_i).value = «»

    }

    for (var i = 0; i < solo.length; i ++) {}

    var line = i + 1

    var a = getField ("ClassName" + row)

    a.Value = solo [i];

    }

    So when the box is checked, the hidden field ClassN1 contains no "Own Selection - less than 8 years" and I want it to fill a Classname field on the next page. " The whole point of this is that there are 40 classes to choose but I want the classes returned from squash in a list without leaving space. However, nothing appears in the field 'ClassName '.... ».

    I had success with this code on an earlier trial but this time it does not work.

    You can see what the problem is?

    On a side note, ClassN field does not fill when I select the checkbox and fill only when I pick up another field or select another location on the page.  Is there a way to force the field to fill in instantly when the box is checked or unchecked?

    Thank you very much in anticipation. Happy to send the file if anyone can help.

    Peter T

    Found my answer.

    I needed to have domain names with an incremental number at the end of the field to make Javascript work to squash to the top of my list...

    Phew!

    Peter.

  • Help with Javascript Code

    I have need of a few write him a fast JavaScript code. I have no experience in JavaScript, but enough to know what to understand. I'm helping to write a very simple writable document in Adobe Acrobat Pro. We need a code which would be specific when a checkbox is clicked on it auto fills with information in the other text boxes. In other words: If mailing address is the address of work so she fills out this information. I have included my variables with the correct names below.

    Thank you for taking the time. Can anyone help?

    I need something that will:

    If checkbox = 'On '.

    then 'employment Address1' = Address1

    then "employment Ville1" = Ville1

    then 'employment State1' = State1

    then 'Job postal Code' = Zip Code 1

    then 'employment County' = County1

    then 'job City, State Zip1' = city, State Zip1

    on the other

    If checkbox = "Off".

    each the first variables remains empty and accessible writing.

    Double readings:

    this.getField("Job_State1").value; = this.getField("State1").value;

    has a semicolon which it does not belong. The line should read:

    this.getField("Job_State1").value; = this.getField("State1").value;

    Then all of the code is:

    If (event.value! = "Off") {}

    fill in the fields of employment;

    this.getField("Job_Address1").value = this.getField("Address1").value;

    this.getField("Job_City1").value; = this.getField("City1").value;

    this.getField("Job_State1").value = this.getField("State1").value;

    this.getField("Job_Zip_Code").value; = this.getField("Zip_Code1").value;

    this.getField("Job_County").value; = this.getField("County1").value;

    this.getField("Job_City,_State_Zip1").value; = this.getField("City,_State_Zip1").value;

    else {}

    Clear fields;

    this.getField("Job_Address1").value = "";

    this.getField("Job_City1").value; = "";

    this.getField("Job_State1").value; = "";

    this.getField("Job_Zip_Code").value; = "";

    this.getField("Job_County").value; = "";

    this.getField("Job_City,_State_Zip1").value; = "";

    }

    You need to find how to set each field if only one is updated. The combined field may need to be updated by each field component. I use the blur action on and avoid using personal calculation action.

  • Help with Javascript syntax for dynamic header / footer...

    Hello-

    I am very new to JavaScript, but I managed to frankenstein two snippets of code that work well individually, but I can't understand how to make them work together. I am applying a dynamic header and footer to a large number of documents using the batch. Here are two extracts that work, and if someone could help me to combine them, I would be very grateful!

    for (var pageNumber = 0; pageNumber < this.numPages; pageNumber ++) {var DateStamp = this.addField ("DateStamp", "text", pageNumber, [10, 15, 600, 0]);} DateStamp.textSize = 12; DateStamp.alignment = 'center'; DateStamp.textColor = color.gray; }

    this.setAction ("WillPrint", "this.getField('DateStamp').value = \"THIS DOCUMENT IS VALID FOR 24 HOURS from DATE of PRINTING:-"+ util.printd (" \"mm/dd/yyyy hh: mm tt\", new Date()) "");

    for (var pageNumber = 0; pageNumber < this.numPages; pageNumber ++) {var FilePath = this.addField ("path", "text", pageNumber, [10, 782, 600, 767]);} FilePath.textSize = 10; FilePath.alignment = "left"; FilePath.textColor = color.gray; }

    this.setAction ("WillPrint", "this.getField('FilePath').value = \"File path: \ "+ this.path");

    Thanks in advance for any help!

    The only problem is that your second order setAction is overwhelming the first. Simply combine it with a single command, as follows:

    this.setAction("WillPrint", "this.getField('DateStamp').value = \"THIS DOCUMENT IS VALID FOR 24 HOURS FROM PRINT DATE: \" + util.printd(\"mm/dd/yyyy  hh:MM tt\",new Date());  this.getField('FilePath').value = \"File Path: \" + this.path;");
    
  • Please help with javascript question

    Hi all

    So ive got this piece of javascript-

    $("#verse_inscriptions").on ('change', function() {}

    verse of the var = $(this).children("option:selected").val();)

    If (verse! = "0") {}

    $("#textarea").val ($("#textarea").val () + "" + verse);

    calculateTotal();

    }

    });

    This page http://www.milesmemorials.com/product-GH54.html that I need is to adapt it so that it will allow this function to arrive while also inserting the same information into the textarea - here

    < textarea = "textarea2" id = "textarea2" name > < / textarea >

    So basically I have 2 forms, the first is where customers make their choices/selections and the second form retrieves these choices and inserts them in form2 by attributes "onchange", but the piece of code above that from occur (only on this part of the form 'inscriptions and verses' and 'textarea', which, as you can see both are interrelated).

    Can someone help me with this? I appreciate all help.

    Sorry it's my typo (extra '} ')

    $("#verse_inscriptions").on("change", function() {
            var verse = $(this).val();
            if(verse == "0") verse = "";
            $("#textarea, #textarea2").val(verse);
            processTextarea();
    });
    

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.UK/

  • Need help with JavaScript button to save as an event.

    Hello

    I use Adobe Acrobat X Pro and am totally new to scripting of forms in Adobe (completely new to Adobe Acrobat as well!).  There is a backup on a form button that opens the Save dialog box under using a trigger (the mouse upward) and action (execute a menu item - file > save under... > PDF...) and it works fine, however, I want to now use javascript to change the behavior of the button so that it uses a trigger (the mouse upward) and action (run a JavaScript script) , and I want that JavaScript to combine the text values in two form fields (a location drop down and a date text field) and use this string concateneated + ".pdf" as the file name when he opens the Save as dialog box.  Make sense?

    This is what I added to the button as a JavaScript so far I use a test at this time string ("NewFile.pdf") and add the string that is concatenated to the script after that I know that the script works as it should.

    var NouveauNomFichier = "NewFile.pdf";

    var pathArray = this.path.split("/"); "

    pathArray.pop ();

    pathArray.push (newFileName);

    this.saveAs(pathArray.join("/")); "

    Up to present two questions:

    1. when I click the button nothing happens, no dialog Save as or whatever it is.

    2 when I check the properties of the button depending on the Actions tab shows property to select Action "Performing a menu item", even if I chose previously 'run a JavaScript '.

    Thanks for any help!

    The saveAs method will not work if the code is placed in a key event. It would need to be in a JavaScript file to the folder level, inside a function of confidence, inside a block of app.beginPriv/app.endPriv. Each user must have the JavaScript file to the folder level. The button can then call the code in the file. It will be possible for users of the form?

  • Please help with javascript

    Hi all
    In my application, there is a colujmn in a table with the date field (calendar) and 2 other fields. The user is not allowed to enter later in the date field, I used a javascript script and it worked fine, but later I discovered that this works only for the future date, (not months or year) assume that, if the date is November 15, 2010, the error is thrown, otherwise if the date is October 15, 2010, error is thrown , for dates like December 10, 2010, December 10, 2011... error is not thrown, that is to say in the coming months and the year is NOT thrown.
    I used the code below:
    < script language = "JavaScript" type = "text/javascript" >
    function test (SAVE)
    {
    for (var i = 1; i < = 30; i ++)
    {
    "" var i1 = i + "";
    if(i<10)
    I1 = '0' + i;
    var datval = document.getElementById("f04_00"+i1).value;
    If (datval! = null & & datval > ($v ('P10_FUTURE_DATE')))
    {
    Alert ("You entered at a later date that is not valid.");
    document.getElementById("f04_00"+i1).value = ";
    document.getElementById("f05_00"+i1).disabled = true;
    document.getElementById("f06_00"+i1).disabled = true;
    counter ++;

    }
    on the other
    {
    document.getElementById("f05_00"+i1).disabled = false;
    document.getElementById("f06_00"+i1).disabled = false;
    }
    }
    if(Counter==0)
    {
    doSubmit (SAVE);
    }
    }
    < /script >

    If the incorrect date is selected, the first value in the column is disabled and the other columns fades.
    Another problem I'm facing here is the calendar does not close when you selected the value, I have to close it manually.

    Please help me with the code!

    Hello

    OK - you should check the settings on the report and the process.

    For each column in the report, check that reference parameters owner of the Table, name reference Table and column name of reference are executed correctly. Note that the reference column name must match the name of the column or the name of the alias, as defined by the SQL statement.

    For each process, make sure that the owner, Table and primary key column name are executed correctly - it should be the same for all processes in the form of tables.

    Andy

  • Quad Core will greatly help with the encoding time?

    Currently I use core duo 3.0 gHz and make me a little better than the real-time encoding during the encoding of 720 x 480 mp4 format using H.264 compression.  A quad core is going to help at all?

    First, PE is going to take advantage of multiple cores, even if a middle of the road than quad (like an Intel Q6600 @ 2.4 ghz) will show an improvement over your existing Duo.

    If you move to a high end Quad Q9650 (3.0 GHz), or a Quad i7Core with multi-threading (essentaily 8 threads), you will see a significant improvement of encoding time.

    When Adobe gets to a 64-bit version of PE, will be then entered the promised land...

    If you like the cards processor, see this link:

    http://www.TomsHardware.com/charts/desktop-CPU-charts-Q3-2008/3DMark-Vantage-CPU, 817.html

    Just find your current CPU, and then look at what you get in addition to the one (assuming that money is no object)...

  • Help with Javascript for the button Delete

    Hi, Im new JavaScript and have my code works partially, but the trouble with a nested if-then-else statement.

    I have a page element, P4_COUNT, and if its value is 0, the button Delete will allow the user to delete the record. If the number is > 0, a message should appear stating that the record cannot be deleted. That's what I have so far and it works, but the first ELSE is misplaced. This code is the URL target for my button remove.

    JavaScript:var response; response = confirm ("are you sure you want to delete this POC?'");
    If {(response)
    If (document.getElementById('P4_COUNT').value == 0) {}
    doSubmit ('DELETE');
    }
    }
    else {-this other fires when the user hits cancel on the first question above not what I want, I want another one here who said only: "removal cancelled '"}
    -This one should only be fired if p4_count is not equal to 0
    var answer2;
    answer2 = confirm ('you cannot remove this POC, that this POC is associated with a RIF.');
    If {(answer2)
    Alert ('cancelled deletion');
    }
    else {}
    Alert ('cancelled deletion');
    }
    }


    The above should follow this logic:

    Are you sure you want to delete this POC?
    Yes - if p4_count = 0 then
    delete the record
    on the other
    second line: cannot delete this record
    OK - prompt removal cancelled
    Cancel - prompt removal cancelled
    end if;
    Cancel - prompt removal cancelled


    Help, please. Thank you, Laura

    Published by: user8936524 on May 10, 2010 14:14

    Hello

    Try if it works. I didn't test it

    javascript:if($v('P4_COUNT')*1==0){
    var answer=confirm('Are you certain you want to delete this POC?');
    if(answer){doSubmit('DELETE');}
    else{alert('Deletion Cancelled');}
    }else{alert('You may not delete this POC, as this POC is associated to an FRR.');}
    

    BR, Jari

  • Help with Javascript syntax error

    Hello

    I'm very new to all this. I have manged to write a script that will change the text in the field based on the text of another field. It sometimes "works", but the form freezes and crashes which I assume is because there is something wrong with my script. Any help would be appreciated.

    I put the script in the calculate-> custom calculation script box

    If ((this.getField("Email_Type").value == 'RSVP Reminder')) {}

    Event.Value = "Date:";

    }

    else if ((this.getField("Email_Type").value == 'Login Webinar')) {}

    Event.Value = "Date:";

    }

    else {}

    Event.Value = "";

    }

    I think I solved my problem. It looks like the place to check for each line, I need to declare the variable.

    If ((this.getField("Email_Type").value == 'RSVP Reminder')) {}

    Event.Value = "Date:";

    }

    else if ((this.getField("Email_Type").value == 'Login Webinar')) {}

    Event.Value = "Date:";

    }

    else {}

    Event.Value = "";

    }

  • help with JavaScript errors when opening Dreamweaver CC

    Since 3 days when I opened Dreamweaver CC on my Mac OS 10.8.5, I have 2 different JavaScript errors: "InternalError: unexpected end of data", and "InternalError: cannot decode JSPrincipals" Dreamweaver seems to work ok, with the exception of copy / paste, but couldn't find a way to clean up the errors.

    Ahh... found, had to use go and type in ~/library to get there. Thank you!

  • Need help with javascript...

    I have a form that I want to send. When it creates the email, I have a script which inputs e-mail sender, a subject line that between the body of the text, including the name of the employee as well as the date and the name of the person completing the form from the "empName" field specified in the field 'weekend '. I want to add the totals for each line (regular, vacation and sick). For some reason, the script stops when I try to add row grand totals. When it works, here is my script:

    var oDoc = event.target;
    
    oDoc.mailDoc({
    bUI: true,
    cTo: "[email protected]",
    cCC: "[email protected]",
    cSubject: "Weekly Employee Time Summary for "+empName.rawValue,
    cMsg: "Attached is the Weekly Employee Time Summary for "+empName.rawValue +" for the week ending "+weekEnd.formattedValue
    });
     

    If I just add one line totals, the Send button does not work. Here is the code with the addition of a line total:

    var oDoc = event.target;
    
    oDoc.mailDoc({
    bUI: true,
    cTo: "[email protected]",
    cCC: "[email protected]",
    cSubject: "Weekly Employee Time Summary for "+empName.rawValue,
    cMsg: "Attached is the Weekly Employee Time Summary for "+empName.rawValue +" for the week ending "+weekEnd.formattedValue +". Vacation Total: "+vacTotal.rawValue
    });
     

    Any ideas why it's a failure? Attached is the file itself

    https://drive.Google.com/UC?export=download & ID = 0B3ZhSiIWrwvWUUhfa0hCZlJFX00

    You must write the path to the object, you cannot access the object if it is in the same subform or if it has a similar parent

    You should write this to access your total value inside the table

    Table1.vacation.vacTotal.RawValue

Maybe you are looking for

  • Page HP Diwali Utsav redemption is not available

    Hello I bought a new laptop HP on Diwali and my dealer told me that I'd get 3 years free warranty of HP under Diwali offer but I have to fill in the details online on the HP redemption page to avail the freebee and have also suggested me to go to thi

  • Can any one Know How to submit multiple applications in a presentation?

    I want to make 2 apps in a single package, I don't know how to do. Please suggest!

  • New Smartphones blackBerry torch no more let me use the camera!

    I took exactly 3 photos and 4 v short vids and the use of the camera is not an option more in both modes. It comes up with the message "another application is using the camera at the moment" or words to that effect. Can not see anything that could be

  • blue tooth stack service

    Bought Pavilion dm4 in summer.  All of a sudden get error message every time I start - cannot start the Blue Tooth stack service.  Why and what do I do?

  • Cheking for no difference with XMLDIFF

    HelloI don't know any with XML so apologies if the answer is trivial for many.I want to compare the same object of 2 diagrams to find the differences. I thought about using DBMS_METADATA with XML, examples of the documentation.I use a PL/SQL block, b