0

I have below format of date and need a beloe o.p in momen

 var myDate="2019-01-26"; 
    console.log(moment(myDate,'YYYY-MM-DD 00:00:00').add("2019-01-26 04:00");

expected o/p be 2019-01-26 04:00:00

Mohamed Sahir
  • 2,482
  • 8
  • 40
  • 71

1 Answers1

1

Based on this, and your previous similar questions it seems that you are trying to add a specific amount of time to a moment-defined date. Perhaps the solution is simpler than you expect. The "add" method takes two arguments; a number representing the quantity to be added, and the type of unit (weeks, days, hours, etc.)

var myDate="2019-01-26"; 
console.log(moment(myDate,'YYYY-MM-DD 00:00:00').add(4, "hours");

seems to return the value you are looking for. the momentjs documentation is excellent. https://momentjs.com/docs/

stever
  • 1,232
  • 3
  • 13
  • 21