English 中文(简体)
数字站式
原标题:Digital Stop Watch
  • 时间:2009-12-19 12:18:54
  •  标签:
  • javascript

Hii,

我在磨难方面有投入时间。 在我的申请中,我想包括一个数字站。 时间将像每秒一个数字锁一样发生动态变化。

问题回答

你们可以把摩擦隔1 000个,然后用60个时间接听,再用60个时间取时。 或者,甚至更好,使用模块:

hours = parseInt(milliseconds / 3600) % 24;
minutes = parseInt(milliseconds / 60) % 60;
seconds = (milliseconds / 1000) % 60;

然而,如果你想像02:00 PM 这样的时间,你必须知道你开始计算微秒(即当小秒是“0”时,时间是什么时候)。

我不肯定你的问题是什么,就像你需要帮助的具体部分一样。 即便是你不熟悉瓦查特语,通过按每个增加的因素进行区分,并且把其余因素考虑在内,这样做也非常简单:

var input = ...; // your input time

var millis = input % 1000;
input /= 1000;

var seconds = input % 60;
input /= 60;

var minutes = input % 60;
input /= 60;

var hours = input % 24; // I presume this will be less than 24 anyway)

var entireTime = hours +  :  + minutes +  :  + seconds;

这样做的另一种办法是创建<代码>Date,反对将投入时间移至施工人员;这将代表过去时代的摩擦数量,从而按其价值进行印刷。 视你有什么样的日期格式框架,这可能是一种更为简单的方法,而且肯定会允许在操纵价值方面有更多的灵活性。

只是一种想法——确保你充分了解实际投入。 投入(time, in milliseconds)相对不寻常;我希望这种投入实际上将成为duration。 诚然,这可能是过去午夜的摩擦次数,但确实不能确保它不会占用过去某些其他任意起点的摩擦。

固定支流为10^-3。 因此,每秒一千秒,每分钟60 000次,每小时3600 000次。 因此,1 000毫秒为1秒,6万毫秒为1分钟,3 600 000毫秒为1小时。

这意味着,将摩擦数量从1 000个减少到1 000个,你获得第二秒数,60 000个,你获得几分钟,3 600 000个。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签