我希望一个人能够有 2 个提示。
我已经有了访客时区。这个想法是转换时区。
客人是他的时区,我的是美国东部时间。
我的来宾时区可以正常工作,我无法让另一个提示获取我的时区,并使用时刻进行转换。
到目前为止,这是我所拥有的。我希望能够提示其他人保留他们的时区并将访客时区转换为我的时区
<div id="main">
<div id="chat_bubble" class="container">
<div id="email-container" class="hide">
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email">
<button id="submit-email-btn" class="btn btn-white">Submit</button>
</div>
<div id="question-container" class="hide">
<div id="question" class="question-text">Question</div>
<div id="answer-buttons" class="btn btn-grid">
</div>
</div>
<div id="chart" class="hide"></div>
<div class="controls">
<button id="start-btn" class="start-btn btn">Start</button>
</div>
</div>
<div id="character_image">
<img id="char_1" src="https://i.imgur.com/7eYWqqo.png" alt=""></img>
</div>
<div id="button_menu">
<button id="dark-mode" class="btn">Dark</button>
<button id="restart" class="btn">Restart</button>
</div>
</div>
应该有办法,虽然我不知道是什么
答案 0 :(得分:0)
经过一些讨论,问题似乎是由覆盖函数内部的“window.prompt”方法引起的。当您设置:
var prompt = prompt("What Timezone")
您正在添加一个名为“prompt”的新变量,当您稍后在代码中使用它时,它将优先于内置 window.prompt。您应该将变量重命名为更符合其用途的名称(以及每个变量的唯一名称),如下所示:
// Starts Moment
var moment = require('moment-timezone');
// Prompt to get the timezone
var timezone1 = prompt("Guest Timezone");
var timezone2 = prompt("My Timezone");
// Shows the time in the current timezone
var time1 = moment().tz(timezone1).format();
var time2 = moment().tz(timezone2).format();
// Console logs the Time
console.log(time1);
console.log(time2);
然后,您将有两个格式化的日期字符串(time1 和 time2),每个时区一个。