logo
down
shadow

Adding a time to a Javascript date


Adding a time to a Javascript date

Content Index :

Adding a time to a Javascript date
Tag : javascript , By : Manu
Date : November 27 2020, 05:23 PM

will be helpful for those in need I'm trying to add a time to a date in my Angular application. , You can convert selected time to minutes like below
var appointmentTimeItems = appointmentTime.split(":");
var hoursPart = parseInt(appointmentTimeItems[0]);
var minutesPart = parseInt(appointmentTimeItems[1]);
var minutes = (hoursPart * 60) + minutesPart;

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Adding date/time using JavaScript to my asp.net user control


Tag : javascript , By : woxorz
Date : March 29 2020, 07:55 AM
seems to work fine You have filled out the name field of the element, but it lacks the id needed to find it via getElementById. Also, .text won't do anything, you need to set its value attribute.
Since your input has a limit of 10 characters you might try removing that to show the full date string or you could instead simply write to the table cell with innerHTML or some such method.

Javascript Adding Time for a Future Date


Tag : javascript , By : SachinJadhav
Date : March 29 2020, 07:55 AM
help you fix your problem If you want to add a number of weeks, just add 7 times as many days, e.g.
var now = new Date();
// Add two weeks
now.setDate(now.getDate() + 14);
var now = new Date();
// Add 24 fortnights (48 weeks)
now.setDate(now.getDate() + 24 * 14);
now.setDate(now.getDate() + 24 * 2 * 7);
var start = new Date();
var end = new Date(+start);
end.setDate(end.getDate() + 24 * 14);

alert('Start on: ' + start + '.\nEnd in 24 fortnights: ' + end); 
<script>

function calcLastPayment(start, numPayments) {
  if (typeof start == 'string') {
    start = stringToDate(start);
  }

  var end = new Date(+start);
  end.setDate(end.getDate() + --numPayments * 14)
  return end;
}

// Expect date in US format m/d/y
function stringToDate(s) {
  s = s.split(/\D/)
  return new Date(s[2], --s[0], s[1])
}

</script>

<form>
 <table>
  <tr><td>Enter first payment date (m/d/y):
      <td><input name="start">
  <tr><td>Enter number of payments:
      <td><input name="numPayments">
  <tr><td colspan="2"><input type="button" value="Calc end date" onclick="
           this.form.end.value = calcLastPayment(this.form.start.value, this.form.numPayments.value)
           ">
  <tr><td>Last payment date:
      <td><input readonly name="end">
  <tr><td colspan="2"><input type="reset">
 </table>
</form>

Adding time as a variable into a date - javascript


Tag : javascript , By : baylisscg
Date : March 29 2020, 07:55 AM
should help you out Try it with double quotes like this ... format("D M j Y $startTime") ... as PHP interprets variables inside double quotes.

Calculate date time by adding / subtracting local offset [ Convert any date time , to UTC time format]


Tag : ios , By : George H.
Date : March 29 2020, 07:55 AM
hope this fix your issue Solved this by using localoffset coming from service and with the method available in swift , TimeZone(secondsFromGMT:offset) :
func findFlightTimeInUTCFormat(dateString:String, localOffSet:String) -> Date? {
        let gmtTimeString = dateString

        let formatter = DateFormatter()
        formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
        formatter.timeZone = TimeZone(secondsFromGMT: -6*60*60)
        var finalDate:Date?
        // original string in GMT
        guard let date = formatter.date(from: gmtTimeString) else {
            print("can't convert time string")
            return finalDate
        }
        finalDate = date
        return finalDate
    }

Adding time to date picker date and time results in same date and time. SWIFT


Tag : ios , By : kiirpi
Date : March 29 2020, 07:55 AM
hope this fix your issue There are many problems here.
You actually never make any use of dateFormatter other than creating and then never using convertedDate. So delete that unused code. You have indicated at duration should be in minutes but you treat it as seconds. You need to multiply by 60 to convert it to minutes. All of your code for calculating things such as openingTimeQueryEnd depend on each value being two digits but your code doesn't give the desired results.
openingTimeQueryEnd = Int("\(String(describing: weekday))"+"\(String(describing: hour))"+"\(String(describing: minute))")!
openingTimeQueryEnd = Int(String(format: "%02d%02d%02d", weekday, hour, minute))!
openingTimeQueryEnd = weekday * 10000 + hour * 100 + minute
Related Posts Related QUESTIONS :
  • react put some props after import class
  • Variable is distributed among same components
  • switch class in jQuery/JavaScript for active/inactive state
  • How To Track Outbound Clicks Using Javascript
  • How to get total seconds elapsed since the beginning of the month?
  • Protractor: Stale element reference at "browser.wait(EC.visibilityOf(confDial), FIFTY_SECONDS);"
  • Access to an array inside an object
  • Reseting an JavaScript Interval with different value?
  • Learning Angular for the first time - version 2 or 4?
  • Rendering RSS feed (XML) in React with jquery, why do object values parsed from the feed seem empty?
  • Node.js xml2js http.request tag matching
  • applying texture to custom plane geometry in Threejs
  • How do I pass an Event as a function parameter in HTML written inside JavaScript variable?
  • Interface of object parameter with default value and default property
  • Does using try / catch rather than `.catch` observable operator with XHR requests reduce performance?
  • In IE11 background colors not working on printing
  • TypeScript interface signature "(): string"
  • Is synchronous XMLHttpRequest supported in Internet Explorer 10 and 11?
  • Axios function not returning any values with js
  • How to use firestore TIMESTAMP to create time-stamp in JavaScript
  • Instantiate subclass without constructing
  • Outputing a created object in javascript to a server side JSON file
  • Transition the numeric labels in a bar chart
  • createBottomTabNavigator: hide just one tab from the tabBar
  • iife vs simple statement behavior with document.title
  • showDialogPopup Refresh Page after Click
  • Child component does not set the initial value passed from the parent: ReactJS
  • Nodejs javascript added to button not responding
  • Trying to define a promise.all
  • Python GEE to extract featurecollection timeseries from Landsat imageries
  • How to write negative binary number?
  • Unable to set property of individual object
  • Why Named Function Expression itself cannot assign Name to another Value?
  • How to reset scroll position on single page pagination
  • How to scroll to bottom of page, when a new message is sent - Socket.io
  • How to reconstruct audio blob from a base64 encoded String?
  • How to calculate numbers within an array of objects
  • Using JavaScript to change CSS properties of SVG circles for all circles that was not clicked
  • Is there value in propTypeing repeat required properties at every level of nested components?
  • Call function if variable does not exist in a filter
  • localStorage value doesn't get updated automatically
  • React not updating state with setState correctly inside promises
  • Direct native JavaScript or jQuery method to get containing block of an element
  • Dynamic JSON object to Html Table
  • How to send Id and file to same controller?
  • How to Make a jQuery Table Cell(td) clickable to Run a Function?
  • Prevent the duplicate function onchange event jQuery
  • Reactjs Input Upload doesn't return local URL
  • An unexpected 'StartObject' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected
  • How to filter a JSON Array, with an eventListener input value at keyup
  • How to separate the different properties of filter in css?
  • Why dont work change event of bootstrap input spinner?
  • How to hide overflow text content in react
  • Is there another way to write line 6
  • Cypress - how to find by text content?
  • How to setstate for the dynamic checkboxes in a loop in react?
  • Is display:none safe?
  • How to create a form to change part of a href url of a button?
  • Put many function inside function in Javascript
  • how to exit from loop after a ajax call
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com