View source for MediaWiki:DateTimezones.js

From TwogPedia

You do not have permission to edit this page, for the following reasons:

  • This page provides interface text for the software on this wiki, and is protected to prevent abuse. To add or change translations for all wikis, please use translatewiki.net, the MediaWiki localisation project.
  • You do not have permission to edit this JavaScript page because it may affect all visitors.

You can view and copy the source of this page.

$(document).ready(function(){
// Function to convert UTC time to visitor's timezone
function convertUTCtoVisitorTime(utcTime) {
const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const utcDate = new Date(utcTime + " UTC"); // Ensure 'utcTime' includes 'UTC' to avoid browser timezone offset
const visitorDate = utcDate.toLocaleString('en-GB', {
timeZone: userTimezone,
day: 'numeric',
month: 'short',
year: 'numeric'
}).replace(/(\w{3}) (\d{4})/, '$1, $2');
const visitorTime = utcDate.toLocaleString('en-GB', {
timeZone: userTimezone,
hour: 'numeric',
minute: 'numeric',
hour12: false
});
const timeZoneOffset = (utcDate.getTimezoneOffset() / 60) * -1
return { userTimezone, visitorDate, visitorTime, timeZoneOffset };
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000
1:0

Return to MediaWiki:DateTimezones.js.