I was using the following MySQL event to update the table with the (CURRENT_TIME)+5) every five min. however my plan is was to get the table updated with that time every full 5 min from current time:
e.g., on 12:05 it writes 12:10, on 12:10 it writes 12:15...
So I used to fire the below event at exactly 12:30:00 for example in order to get it accurate.
CREATE EVENT x_next
ON SCHEDULE EVERY 5 MINUTE
STARTS CURRENT_TIMESTAMP
DO
UPDATE data SET x_next= CONCAT(CONCAT(HOUR(CURRENT_TIME),':'),MINUTE(CURRENT_TIME)+5);
What I am looking now is to make it more accurate to make this event act like the following JSfiddle result where if the even started at any time it will update only on the next 5 min (snapped-to):
http://jsfiddle.net/v06jrobg/
Where the result should be what the event should update.
I am wondering if anyone had this experience before or any suggestions?
Try to define a start time instead of current_timestamp
CREATE EVENT x_next
ON SCHEDULE EVERY 5 MINUTE
STARTS '2014-10-08 12:00:00'
DO
UPDATE data SET x_next=
CONCAT(HOUR(DATE_ADD(Now(),INTERVAL +5 MINUTE)),':',
MINUTE(DATE_ADD(Now(),INTERVAL +5 MINUTE)));
This will start at 12:00:00 and execute every 5 minute.
I changed your update syntax a bit also. It makes sure that the hour is added with 5 minutes, in case at 16:55 , the next value is 17:00. I think this will give 17:0 and not 17:00, might have to fix a check for that. A bit hacky but it might do the trick?
Related
When I use this code even if I change the value of the "seconds" variable, it always starts the "PresaTavOff" function at 1 minute and 20 seconds, even if as a value 50 seconds or 1 second
function doGet() {
var seconds = 10
UrlFetchApp.fetch('https://maker.ifttt.com/trigger/trigger_name_1/with/key/api');
ScriptApp.newTrigger('PresaTavOff')
.timeBased()
.after(seconds*1000)
.create();
}
function PresaTavOff(){
UrlFetchApp.fetch('https://maker.ifttt.com/trigger/trigger_name_2/with/key/api');
}
I also tried:
var seconds = parseInt(10)
The code works and does everything, only the wait that doesn't respect the time I give it.
what am I wrong?
Thanks
There is an open issue for time based trigger could not fire after few seconds, which has been acknowledged by Google and reported internally.
Whilst the documentation specifies that time based triggers are set after x milliseconds my experience is that they never run exactly after the specified time. I've not seen any official documentation on limitations of the .after() method, but Google do say when installing repeating time based triggers the "the time may be slightly randomized".
I have FlipClock code as following
var clockDuration = $('.clock-duration').FlipClock({
// ... your options here
});
Clock working fine but I have requirement as follows
For e.x - Normally Clock start as 00:00(mm:ss) and after 60 seconds it shows 00:59(mm:ss) and after that it will change minute 01:00(mm:ss) but I want change this when clock start it should be started as 00:01 and after 60 seconds it should shown as 00:60 and after that 01:00
Basically I need to change FlipClock start and end seconds setting
Can you please help me out from this stuck?
I refer following site for this but not found solution for this
FlipClock
With such requirements I can see only 4 solutions:
Change core code of FlipClock javascript file.
Make javascript callback funcion on seconds change in FlipClock and change text in time block manually. It's pretty complex with many exeptions that will be finded.
As you want to show after 60 seconds time: 00:60 and then 01:00, so you want in 1 second show 2 seconds... That's very strange behavior that makes no sense and no real profit. Best solution - give up in this idea, because it will cost much time with bad results in the end.
Make your own timer.
I think 3 is best. Next best is 4 alternative.
I have been tasked with creating a clientside countdown timer for a list of records. Each record has a value like I specified in the title (Example: Tuesday,05:00). I need to show a running countdown on each row in an Angular 4 application so that if the current time was the day before at 02:30, the value would display as '1d 2h 30m'. I am currently having a total block on how to get started and would appreciate any feedback for turning the next instance of 'Tuesday,05:00' into a usable date/time value to work with.
MomentJs + coundown plugin + (optionaly natives support for momentjs)
As simple as 1 liner:
console.log(moment("1982-5-25").countdown().toString());
For non-english find your desired moment locale.
There couldn't be possibly a simpler and more quality solution that one can write in the 5 min time it takes you to setup this.
I have made a countdown timer. It uses the date function to get the current time. Then it stores that time in another var. This new var gets changed hours/minutes/seconds, so the format should be the same as the date function.
Then I turn both variables into time since counting, in milliseconds.
Then I substract the current date from the new date thingy, to get the time difference from both variables in milli seconds. This should be the difference from the current time to the target time.
After this, I will turn the difference into a readable hours/minutes/seconds timeformat, which will be displayed in a div. Also added a piece of code for allowing an blinking countdown timer, which will give 5 minutes extra time if the timer has run out. (this countdown timer should be part of a larger script, doing things)
BIG PROBLEM IS: The timer works. Does everything I want it to do. But it's very laggy! It skips displaying seconds, even if I set the setTimeout to 10 ms. I also use a clock using the same timer set-up (different vars), and that clock doesn't skip any time, with a setTimeout of 1000 ms...
Tryed to make some calculations smaller, even read alot about the setTimeout and setInterval drift in javascript, but this doesn't explain my current problems. (using setTimeout for a chat, to reload messages every 500 ms, and that works like a charm so my computer/client/server can handle smaller then 1000 ms times)
Skipping seconds happens on IE and firefox. Other countdown timers (which don't do what I want them to do) also run fine in my browser. What's the problem here?!?
https://jsfiddle.net/77cnvq82/
function startMyFunction() {
setTimeout(myFunction, 100);
}
In this example, the speed has been set to 100ms
The actual issue is in your rounding and math, not in the display code itself.
If you change your display line to:
timerShowRemaining = timerShowRemaining+timerHours+":"+timerMinutes+":"+timerSeconds
+ (new Date());
It will display the current time and you'll see the seconds count up evenly, even as your calculated numbers jerk and lag.
I am asking help for a problem which I am not able to solve despite every effort. I am trying to make a counter. This counter is to be placed in a div under the available items on a webpage. This counter should be able to change its value at predefined values and intervals, for example, the value starts at 5,000 at then decreases by 1 after 2 seconds and then by 4 after next 5 seconds and then by 3 after next 2 seconds and then the process repeats (decreases by 1 after 2 seconds...) three or four sets of variation will be enough.
The value shown by the counter must not be affected by the number of page loads or simultaneous users, also it should remain if the user sees the page in two different browsers, it must only be shown as described above.
This counter must be capable of changing its value without needing the user to refresh the page.
Most straightforward solution as it appears to me would be to make the timer relative to absolute time.
This means you take the time passed since an arbitrary point in time you define as the start, e.g. right now which is var start = Date("Thu Jun 04 2015 01:46:44 GMT+0200 (CEST)") here. You can now subtract start from the current time to learn how much time has passed:
var passedSeconds = (new Date() - start) / 1000;
We divide by 1000 since JS calculates with miliseconds by default.
To update the timer, do a simple
setInterval(function() {
var passedSeconds = (new Date() - start) / 1000;
var value = doCalculationForSeconds(passedSeconds);
document.getElementById('myDisplay)'.textContent = value;
}, 1000);
which calls this method every second.
Lastly, you need to figure out a good way to calculate the progress. You could either run your formula in a big loop for all of passedSeconds. Or you evaluate if you can reduce it to a single calculation step. Will depend on the exact changes in value you'll have in your final version.