# Counting time from and to

**URL:** <https://community.thunkable.com/t/counting-time-from-and-to/2200856>\
**Category:** Questions about Thunkable X\
**Tags:** time\_picker\
**Created:** [January 1, 2023, 9:38pm UTC](https://community.thunkable.com/t/counting-time-from-and-to/2200856 "2023-01-01T21:38:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![oleksiy.lavrynenko](https://avatars.discourse-cdn.com/v4/letter/o/a88e4f/32.png) [@oleksiy.lavrynenko](https://community.thunkable.com/u/oleksiy.lavrynenko)\
**Post date:** [January 1, 2023, 9:38pm UTC](https://community.thunkable.com/t/counting-time-from-and-to/2200856/1 "2023-01-01T21:38:09Z")

</div>

Friends, do you need your advice (maybe someone faced such a problem)?

You have to count working hours. The user enters the start of the job and the end of the job, and the program outputs the amount of time spent on the job.

I can’t figure out how to calculate the logic correctly ☹  
Yes, if a person worked for more than an hour, then we subtract the start time from the end time of work - we get the number of hours.  
What to do with minutes? If a person started working, for example, at 13.30, and finished working at 14.10, then:

1. We count the hours: 14-13 = 1
2. We count the minutes: 10 - 30 = -20, which is clearly not correct.

Question: how to get out of this situation?  
Thanks in advance for your answers - comments.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 1, 2023, 11:11pm UTC](https://community.thunkable.com/t/counting-time-from-and-to/2200856/2 "2023-01-01T23:11:08Z")

</div>

Convert the start time to seconds since 1970, convert the end time to seconds since 1970, subtract one from the other, and then convert the answer into hours and minutes.

You may need JavaScript to accomplish all of that.

---

<div class="post-metadata">

**Author:** ![oleksiy.lavrynenko](https://avatars.discourse-cdn.com/v4/letter/o/a88e4f/32.png) [@oleksiy.lavrynenko](https://community.thunkable.com/u/oleksiy.lavrynenko)\
**Post date:** [January 1, 2023, 11:14pm UTC](https://community.thunkable.com/t/counting-time-from-and-to/2200856/3 "2023-01-01T23:14:49Z")

</div>

Hm…interesting…forgive my impudence - maybe you have an example?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 1, 2023, 11:39pm UTC](https://community.thunkable.com/t/counting-time-from-and-to/2200856/4 "2023-01-01T23:39:45Z")

</div>

I don’t have an example but if you Google _calculate time between two times javascript_ you can find some instructions. It’s probably also possible to use a Google Sheet formula to calculate this.

---

<div class="post-metadata">

**Author:** ![oleksiy.lavrynenko](https://avatars.discourse-cdn.com/v4/letter/o/a88e4f/32.png) [@oleksiy.lavrynenko](https://community.thunkable.com/u/oleksiy.lavrynenko)\
**Post date:** [January 1, 2023, 11:42pm UTC](https://community.thunkable.com/t/counting-time-from-and-to/2200856/5 "2023-01-01T23:42:49Z")

</div>

Understood thanks 🙂  
I looked in the direction of Google Spreadsheets, but there is an option to calculate time immediately as a mathematical operation - but this doesn’t suit me, because I don’t work with Google Spreadsheets in this case.

---

<div class="post-metadata">

**Author:** ![oleksiy.lavrynenko](https://avatars.discourse-cdn.com/v4/letter/o/a88e4f/32.png) [@oleksiy.lavrynenko](https://community.thunkable.com/u/oleksiy.lavrynenko)\
**Post date:** [January 2, 2023, 7:56pm UTC](https://community.thunkable.com/t/counting-time-from-and-to/2200856/6 "2023-01-02T19:56:37Z")

</div>

Friends, my head is boiling 🙂  
So, we have a date and time input.  
We also have a block “Seconds since 1970”.  
Tell me how to get the number of seconds from 1970 from the date and time entered by the user?

Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [April 2, 2023, 7:57pm UTC](https://community.thunkable.com/t/counting-time-from-and-to/2200856/7 "2023-04-02T19:57:27Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
