Created
August 6, 2014 01:35
-
-
Save DeskWOW/6e88c4d09174b37da885 to your computer and use it in GitHub Desktop.
By adding a bit of code to "Email (New)", you can set a customer custom field to the user's timezone. Before adding code to your support center theme's contact form, create a customer custom field with key "time_zone" and with the 4 values used below.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Add this right above {{form_end}} --> | |
<div class="timezone-div">{{ customer_custom_time_zone }}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Add this script to the very bottom of Email (New) --> | |
<script> | |
function getTimeZone() { | |
return /\((.*)\)/.exec(new Date().toString())[1]; | |
} | |
$(function() { | |
timezone = getTimeZone(); | |
if (timezone == "EDT" || timezone == "EST") {value = "(GMT-05:00) Eastern Time (US & Canada)"} | |
else if (timezone == "CDT" || timezone == "CST") {value = "(GMT-06:00) Central Time (US & Canada)"} | |
else if (timezone == "MDT" || timezone == "MST") {value = "(GMT-07:00) Mountain Time (US & Canada)"} | |
else if (timezone == "PDT" || timezone == "PST") {value = "(GMT-08:00) Pacific Time (US & Canada)"} | |
else {value = "---"} | |
$(".timezone-div select").val(value); | |
}); | |
</script> |
We list all timezones in this article: https://support.desk.com/customer/portal/articles/2148835?b_id=7112
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What if we need to identify timezones around the world?
I can add more else if statements, but what are the time zone and value formats within the getTimeZone function?