The simple answer is to convert the date into milliseconds since Epoch and add the timezone offset and convert it back to a date object. In JavaScript, the getTime() function returns the number of milliseconds since the Unix epoch time. The Modern Node.js Alternative, How to console.log with colors in JavaScript, The Best Way to Set Up Function Parameters in JavaScript, Destructuring Assignments in JavaScript By Example, How to Get the Substring Before a Character in JavaScript, How to Iterate Through JSON Objects in JavaScript, How to prevent HTML5 video from changing size when loading a new source, How to Build an Angular 9 App That Connects with a REST API, How to Fix the "Property does not exist on type {}" Error in TypeScript. Overrides the Object.prototype.valueOf() method. © 2005-2021 Mozilla and individual contributors. JavaScript. To create a new instance of the Date object, use the new keyword: const date = new Date(); The Date object contains a Number that represents milliseconds passed since the Epoch, that is 1 January 1970. Found inside... for the calculation of the relative cookie expiration date: Click here to view code image