Google Calendar's embed code inserts a "ctz" variable in the URL to set the appropriate display time zone, however I'm working with more than 500 users on a global website and trying to keep everyone clear on scheduling (non-paying language learners, otherwise I'd just hire an expert).
Does anyone have advice on how to set the user's time zone based on their IP address? I've already scanned the questions quite extensively through the day.
How Calendar uses time zones. When you create an event, you'll see it in your local time zone. It will also show up in the local time zones for anyone you invite, even if they're in a different time zone. Reminders always show up at the same hour regardless of time zone.
Use the JSTZ library e.g. via cdnjs by including a script tag in the like
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.7/jstz.js"></script>
Then put a script tag just before the closing tag that:
So if your calendar embed iframe tag looks like:
<iframe src="https://www.google.com/calendar/embed?showPrint=0&showCalendars=0&mode=WEEK&height=600&wkst=1&bgcolor=%23FFFFFF&src=somecalendaridentifier%40group.calendar.google.com&color=%23AB8B00&ctz=America%2FLos_Angeles" style=" border-width:0 " width="800" height="600" frameborder="0" scrolling="no"></iframe>
Your script would look like:
<script type="text/javascript">
var timezone = jstz.determine();
var pref = '<iframe src="https://www.google.com/calendar/embed?showPrint=0&showCalendars=0&mode=WEEK&height=600&wkst=1&bgcolor=%23FFFFFF&src=somecalendaridentifier%40group.calendar.google.com&color=%23AB8B00&ctz=';
var suff = '" style=" border-width:0 " width="800" height="600" frameborder="0" scrolling="no"></iframe>';
var iframe_html = pref + timezone.name() + suff;
document.getElementById('calendar-container').innerHTML = iframe_html;
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With