Date issue [Solved]

I want to add x month to a date entered in a form.
When I use Webix.date.add I get strange results

var dtDate = $$("myForm").getValues().startDate;
console.log(dtDate);
var dtOrgDate = webix.Date.strToDate("%Y-%m-%d %H:%i:%s")(dtDate);
console.log(dtOrgDate);
console.log(newValue);
var dtNewValue = webix.Date.add(dtOrgDate, newValue, "month", true);
console.log(dtNewValue);

Will result in
details.js:489 2019-07-22 00:00:00
details.js:491 Mon Jul 22 2019 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
details.js:492 12
details.js:494 Wed Jan 22 2070 00:00:00 GMT+0100 (Mitteleuropäische Normalzeit)

What is the problem with this code?

Comments

  • Most probably, newValue is a string in your case

    Try to update code like next, to ensure that newValue is a number

    var dtNewValue = webix.Date.add(dtOrgDate, newValue*1, "month", true);
    
  • That's it. Thank you

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion