JS time addition and subtraction method

tags: vue  uni-app  javascript  elementui  Development language

function addTime(strDate,strFlag,value){
  if(strFlag=="H")
  {
     value = value *60*60
  }
  else if(strFlag=="D")
  {
     value = value*60*60*24
  }
  var datacurpar = date.parse (new date (strdate))/1000; // convert to a timestamp
     datacurpar = datacurpar + value; // Time stamp after 5 days
     var datadefpar = new date (PARSEINT (datacurpar) * 1000); // Convert to time
  var year = dataDefPar.getFullYear()
  var month = dataDefPar.getMonth() + 1
  var month = month<10? "0"+month : month
  var Day = dataDefPar.getDate()<10? "0"+dataDefPar.getDate():dataDefPar.getDate()
  var Hours = dataDefPar.getHours()>=10?dataDefPar.getHours():"0"+dataDefPar.getHours()
  var Minutes = dataDefPar.getMinutes()>=10?dataDefPar.getMinutes():"0"+dataDefPar.getMinutes()
  var Seconds = dataDefPar.getSeconds()>=10?dataDefPar.getSeconds():"0"+dataDefPar.getSeconds()

  var dataDef = year+ '-' + month + '-' + Day+" "
  +Hours+":"+Minutes+":"+Seconds
  return dataDef
}

Intelligent Recommendation

JS bit operation and addition and subtraction method

Bit operation Position and (&) It's true, the rest is false Application: judge the strange puppet The binary of the binary binary is 1, the even number is 0, and the bit and operation of the 1 are...

JS time period selection, JS timestamp, addition and subtraction, time every second, addition and subtraction

As shown in the figure above: When I chose "within one week", I had to intercept the time within the seven days of the current time (the seven days today is the start time, and the end time ...

More Recommendation

Golang time addition and subtraction

Add and Sub usage in the time package, Add is used to calculate the time before and after a certain time, Sub is used to calculate two time differences  ...

Time addition and subtraction in the database

The result of the calculation is not a data that can be used for calculation and cannot be used for direct time conversion. 1、UNIX_TIMESTAMP The result is seconds, which can be used to calculate the y...

Oracle time addition and subtraction

1, function: ADD_MONTHS (DATE, INTEGER) -- plus the specified time plus the time after months E.g: 2. Add or subtract SYSDATE for one time. E.g: In the same way, if it is minus (-), it is time to push...

PostgreSQL time addition and subtraction

addition: Subtraction: Reverse operation required...

Addition and subtraction of time in Java~

There are many methods of time calculation in java, I think the best one is this one:   ok. OutputresultDate6It's the time you want  ...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top