roundDate

rounds the specified date to the nearest date in the time scale

Date roundDate(Date | RoundDateConfig date);
dateDate | RoundDateConfigthe Date object to round or an object with settings
Datethe rounded Date object

Example

var today = gantt.roundDate(new Date());

Details

If the specified date should be rounded to the nearest date, pass the Date object as a parameter to the method:

var today = gantt.roundDate(new Date());
console.log(today);

If the specified date should be rounded to the nearest date considering the unit of time, pass an object with settings to the roundDate() method. The object can take the following attributes:

  • date - (Date) - the Date object to round;
  • unit? - (string) - the time unit ("minute", "hour", "day", "week", "month", "year");
  • step? - (number) - the step of the time scale (X-Axis), 1 by default.
var today = gantt.roundDate({
    date: new Date(),
    unit: "hour",
    step: 1   
});
console.log(today);
See also
Back to top