Error in making timer

I am making a app that can set timer for 35 days from current date.so can you tell what error in these block.

Why not just tell what is happening and what you would expect.

1 Like

Just this ?

image

4 Likes

You are doing several things wrong.

  • A Formatted date is the worst possible way to store a date if you plan on doing math with it or comparing it against another date. Milliseconds (from 1970) is the only way to store dates for that purpose.
  • Hover your cursor over the Clock1.Duration block in the Blocks Editor and tell us what it says that block should be fed for start and end. Instants? Milliseconds? Formatted dates?
  • look at your inputs to Clock1.Duration. You are feeding it the same value for start and end. How could it return anything but 0 (aside from choking on the wrong type of input)?
  • Look at your math. You convert milliseconds to days with that division, but you are feeding it a variable named days_elapsed. It would surprise me if it actually held milliseconds, with a name like that. (Not that you actually showed us where it got its value.)
1 Like

I have corrected the blocks but again it is showing error


read the error message
as you can see, the first argument is not an instant

unknown

clear TinyDB and restart testing
Taifun

2 Likes

I cleared then it showed this error

oh yes... sorry, I have overseen it...
this is because in TinyDB you can't store instants...
they look like instants, but are not instants anymore after getting them back from TinyDB

if you really want to use TinyDB to store your start date, you have to store it as millis and convert it back into an instant... the clock component offers a method for that

Taifun

1 Like

Thanks :smiley:

(added to FAQ)

1 Like