javascript 时间行情指示器

发布于 2024-12-05 20:21:27 字数 360 浏览 1 评论 0原文

我想构建一个简单的时间自动收录器。

基本上,我将从服务器端注入一个全局 JavaScript 变量,它将在我的业务模型中代表代理的活动任务开始时间。

我想在标签中显示全局日期和现在之间的数字时间格式,但我遇到的问题是这两个日期之间的差异的毫秒数。

我已经创建了一个 JSFiddle 但 new Date() 和该特定日期之间的差异没有正确显示。

在此处输入代码http://jsfiddle.net/alexpeta/ZmzDh/3/

你们能发现错误或问题吗?

I want to build a simple time ticker.

Basically I will have a global javascript variable injected from the server side that will represent in my business model a active task start time for an agent.

I want to show in a tag the digital time format between that global that date and now, but the issue I have is with the milliseconds from the difference between those 2 dates.

I have created a JSFiddle but the difference between new Date() and that specific date is not showing properly.

enter code herehttp://jsfiddle.net/alexpeta/ZmzDh/3/

Can you guys spot the bug or the issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

じее 2024-12-12 20:21:27

d.toLocaleString() 可能有话要跟你说;)提示:不,您测量的不是 9 月 22 日以来的时间,而是测量到 10 月 22 日的时间。

http://jsfiddle.net/LDKh7/

d.toLocaleString() might have a word with you ;) tip: no, you are not measuring time since September 22, you are measuring time to October 22.

http://jsfiddle.net/LDKh7/

帅气尐潴 2024-12-12 20:21:27

示例

将:替换

var t = setInterval('tick()',1000);

为:

var t = setInterval(tick,1000);

使用函数引用和setInterval 中不是字符串

Example

Replace:

var t = setInterval('tick()',1000);

with:

var t = setInterval(tick,1000);

It's always a good idea to use function reference and not a string in setInterval

揽月 2024-12-12 20:21:27
 <script language="JavaScript">
  TargetDate = "12/31/2020 5:00 AM";
  BackColor = "palegreen";                   
  ForeColor = "navy";                    
  CountActive = true;                   
  CountStepper = -1;                 
  LeadingZero = true;                            
  DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%%   Seconds.";                      
  FinishMessage = "It is finally here!";                  
   </script>
  <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script>  
 <script language="JavaScript">
  TargetDate = "12/31/2020 5:00 AM";
  BackColor = "palegreen";                   
  ForeColor = "navy";                    
  CountActive = true;                   
  CountStepper = -1;                 
  LeadingZero = true;                            
  DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%%   Seconds.";                      
  FinishMessage = "It is finally here!";                  
   </script>
  <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script>  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文