问题标签 [elapsed]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
6 回答
59337 浏览

c - 如何以毫秒为单位获取 C 中经过的时间?(视窗)

我在网上搜索过,但我只找到了一种方法,但这样它会以秒而不是毫秒返回。

我的代码是:

0 投票
2 回答
13837 浏览

c# - Show "Time Left" from a set date to now

I have an application that, when a certain action occurs, the exact DATE/TIME is written as myTime using the Visual studion configuration manager where you can add settings.

This is my setting : Properties.Settings.Default.voteTime

I want as soon as my application starts to show a label that will display "X time left until next vote request"

In my context, the votes must be done each 12 hours so

I want the label to basically show how much time is left from those 12 hours, starting from the voteTime I mentionned above.

I have tried many techniques but I'm a noob at C# and noone worked for me, each time the label either had his default text or was blank...

Above, that is what I tried then I wrote label1.text = countDown;

Thanks in advance.

0 投票
3 回答
2639 浏览

android - What does System.nanoTime() return in Android?

I have a bunch of activities tied together, one into the next and so on. Now during one activity I want to measure elapsed time. As I understand, I would use System.nanoTime() to find the start time, the user does some things, then use it once more to find the end time, subtract the two and voila my elapsed time spent on the activity. But suppose something happens while my activity is running: I already have created the start time, but now the user gets a phone call or something, my activity is put into the background. The phone call ends and the user returns to the activity. Was the timer running the whole time, even while the app was in the background? Is the timer 'reset' since I left the app then came back to it?

Also, when I do initiate System.nanoTime() is it returning the time since the start of that particular activity or the main activity?

EDIT: Suppose I set the first tickmark at a certain point, then the app goes into the background, then it returns to the foreground and I set the second tickmark. Ideally I want the time elapsed along with the time spent in the background; does System.nanoTime() achieve this?

0 投票
1 回答
1009 浏览

android - 使用新的 youtube API 库获取经过的 youtube 视频时间

我想使用新的 Android Youtube API 播放 youtube 视频。我从 google (YouTubeAndroidAPIDemo) 下载了演示项目,这是我用来启动视频的代码:

这运行 youtube 视频没问题,但是,当用户按返回键时,我想知道经过的时间(例如,youtube 视频的大小是 3:01,但用户只看到了 50 秒)我怎么知道经过的时间? 谢谢!

0 投票
1 回答
451 浏览

c# - 使用 Windows Timer elapsed 事件的录音问题

我正在按时间间隔从我的 Windows 应用程序录制语音。我做了一个类来开始和停止录音并在我的表单上调用它的功能。

班级如下

现在,当我在按钮单击事件上调用这些函数时

一切都很好,无论我点击按钮的速度有多慢,代码总是会创建编号文件。

我将代码放入一个循环中,就像

它也运行良好并创建了 10 个编号的文件。

到现在一切都很好,在这里我介绍了这样的 Timer

现在的问题是当代码在 TimerEvent 中执行时,它正在创建文件,但它也丢失了一些文件。

例如
循环创建:1.wav、2.wav、3.wav、4.wav、5.wav、6.wav
定时器创建:1.wav、2.wav、4.wav、7.wav、8.wav , 13.wav

我已经调试了代码,每条语句每次都在执行,但有时文件没有被创建。

任何帮助将不胜感激:)

0 投票
0 回答
148 浏览

java - Java 奇怪的行为:使用 println 的运行时间更快

我在 Java 中看到了一些奇怪的行为:
注释 aprintln会使函数执行速度变慢。
取消注释println会使函数执行得更快。

我希望这会被扭转,因为println应该花费时间。

触发器是函数System.out.println("");中的。 注释行后,我得到 2.5 秒。 在未注释该行的情况下,我得到 1.9 秒。sequentialProcessData

该行为独立于使用nanotime()currentTimeMillis()测量时间。

println此外,在使用标志触发时,我无法重现该行为。

使用 Eclipse、jdk1.7.0_51 (JavaSE)、Windows 7(8 核,以防万一)进行测试。

谢谢

编辑
此行为仅在我在 Eclipse 中编译代码时发生。(在 Eclipse 和 shell 中运行都有这种奇怪的行为)
如果我在 shell(javac Main.java)中编译,那么行为是正常的,即 println 版本较慢(大约 1 秒)。

Eclipse 编译器有什么奇怪的地方吗?

代码:

0 投票
4 回答
310 浏览

perl - Perl:如何知道 24 小时是否已过?

我在 mysql 表上有一个时间戳字段,我想知道该时间戳是否为 24 小时或更长时间。在 Perl 中最好的方法是什么?

0 投票
1 回答
169 浏览

c# - 仅在完成当前迭代后才计算经过的时间,然后再进行新的迭代

我试图制作一个每 5 秒运行一次代码的计时器。但是这 5 秒只能在当前代码运行完毕后才算。

例子:

结果:

预期结果:

有没有办法只在当前事件结束后计算经过的时间?

一件重要的事情:我可以使用的唯一类是 System.Timer.Timer,我不能使用 Thread.Sleep 或任何类型的递归方法。

谢谢,我很感激你的回答=)

0 投票
1 回答
603 浏览

php - PHP在foreach循环中查找自日期时间以来经过的时间

我正在寻找一个解决方案:我在幻灯片中有一个 foreach 循环(帖子),我需要检索自发布日期以来经过的时间。我正在关注这个线程PHP How to find the time elapsed since a date time? 这就是我到目前为止所做的,但它不起作用,它破坏了幻灯片,或者我收到了一个关于 $time variabe 的错误,无法重新清除。有人可以帮忙吗?谢谢。

0 投票
2 回答
1827 浏览

c++ - 以 24 小时格式表示的两个时间之间的经过时间 hh:mm:ss

嘿,感谢您的加入。我只是想说,如果有人以前遇到过这个问题,我会道歉。

我花了几个小时在论坛和谷歌上搜索类似的问题,但到目前为止还没有运气。

我对这个程序的意图是打印出两个时间之间的经过时间,格式为 24 小时。

截至目前,我想我只是想将经过的第一个和第二个“hh”转换为正确的 24 时间,但无法理解如何做分钟和秒。

我非常感谢任何指导,这将非常有帮助。干杯。