Most of the time is how long you spent playing the puzzle (although doesn't include any time with the screen off or out of the app!).
If you make any mistakes then you may get a penalty added. If you make more than 3 mistakes then there is a time penalty added of 5 seconds per mistake.
If you ask for hints, and continue asking so that it gives you more details and eventually gives you the answer, then that will add time too.
The first one will be at a very low cost of 5 seconds, the second will be 10 seconds, the third 15 seconds, etc. If you just fill in the whole puzzle using hints you'll quickly add up an hour or more of extra time!
Note that the hints only cost time if they actually get as far as putting in the value for you. They're completely free for helping you to find areas and cells to look in!