I already tried the codes below, but they don't work because they include Date and\or Time. I need to get only the timezone name. (OBS: timezone name, not IANA Time Zone)
Is it possible to force toLocaleString() to show timeZoneName "short" and "long" at same time?
Example: 5/2/2021, 02:34:28 GMT+12:45 Chatham Standard Time
<!DOCTYPE html> <div id="Output"></div> <script> Date_Object = new Date(); document.getElementById("Output").innerText = Date_Object.toLocaleString([], {timeZoneName:"short"}) + "\n" + Date_Object.toLocaleDateString([], {timeZoneName:"short"}) + "\n" + Date_Object.toLocaleTimeString([], {timeZoneName:"short"}) + "\n" + "\n" + Date_Object.toLocaleString([], {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleDateString([], {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleTimeString([], {timeZoneName:"long"}) + "\n" + "\n" + Date_Object.toLocaleString("en-US", {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleDateString("en-US", {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleTimeString("en-US", {timeZoneName:"long"}) + "\n" + "\n" + Date_Object.toLocaleString("pt-BR", {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleDateString("pt-BR", {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleTimeString("pt-BR", {timeZoneName:"long"}) + "\n" + "\n" + Date_Object.toLocaleString("ja-JP", {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleDateString("ja-JP", {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleTimeString("ja-JP", {timeZoneName:"long"}) + "\n" + "\n" + Date_Object.toLocaleString("ar-SA", {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleDateString("ar-SA", {timeZoneName:"long"}) + "\n" + Date_Object.toLocaleTimeString("ar-SA", {timeZoneName:"long"}) + "\n" + ""; </script>
没有评论:
发表评论