How to remove the impact of time zone?

There is a function:
toDate(date, time){
 let d = new Date(date + '' + time);
 return d;

to date give 2017-03-09
in time pass 03:30:00

The output is 2017-03-09T00:30:00.000 Z, ie-3UTC
How to remove this offset?
And at the same time how to get this format: dd/mm/YYYY HH:mm ?
June 27th 19 at 14:58
2 answers
June 27th 19 at 15:00
Inside, the Date object does not store an indication of a time zone, he believes the time is always in UTC and value only stores the number of milliseconds since 1970-01-01 00:00:00 UTC. He is well aware of the time zone of the device, and can take it into account when forming a conclusion.

In the constructor when Date is passed only 1 argument (your case), this argument is interpreted as the time in the UTC zone; when more than one local time zone.

As I understand it, you want to create a Date object by passing the date-time in UTC?

Try this:
function toDate(date, time) {
 return new Date( Date.UTC( date + '' + time));

Format dd/mm/YYYY HH:mm you can get, making of the component. Again, according to UTC or in local time? For UTC will look like this:
function pad(n){ return ('0' + n).substr(-2) }
function toUTCString(d) {
 return " + pad( d.getUTCDate()) + '/' + pad(d.getUTCMonth()+1) + '/' + d.getUTCFullYear()
 +' ' + pad( d.getUTCHours()) + ':" + pad( d.getUTCMinutes());

In the local time zone of the device – remove the 'UTC' from all methods )
If we use ES6, then it is appropriate to write const instead of let.
Or this:
const toDate = (date, time) => {
 return new Date( Date.UTC( date + '' + time));

Or so:
const toDate = (date, time) => new Date( Date.UTC( date + '' + time));
- trystan.Powlowski55 commented on June 27th 19 at 15:03
June 27th 19 at 15:02
but as something without external libraries it can be done? - trystan.Powlowski55 commented on June 27th 19 at 15:05

Find more questions by tags JavaScript