Skip to content

Commit

Permalink
Merge pull request #1182 from internetee/1171-portal-must-use-browser…
Browse files Browse the repository at this point in the history
…-timezone

add converter timezone for local
  • Loading branch information
vohmar authored Nov 21, 2023
2 parents 0c072eb + 407bafd commit c7add38
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/packs/entrypoints/controllers/countdown_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ export default class extends Controller {
}

timeDifference() {
return this.endTime - new Date().getTime();
const convertedToTimeZone = this.convertDateToTimeZone(new Date().getTime(), 'Europe/Tallinn');
return this.endTime - new Date(convertedToTimeZone).getTime();
}

convertDateToTimeZone(date, timeZone) {
return new Intl.DateTimeFormat('en-US', {
timeZone: timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
}).format(date);
}
}

0 comments on commit c7add38

Please sign in to comment.