# How to create a function in bubble

**URL:** <https://forum.bubble.io/t/how-to-create-a-function-in-bubble/227396>\
**Category:** Need help\
**Created:** [October 7, 2022, 1:00pm UTC](https://forum.bubble.io/t/how-to-create-a-function-in-bubble/227396 "2022-10-07T13:00:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcleonis](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jcleonis/32/115531_2.png) [@jcleonis](https://forum.bubble.io/u/jcleonis)\
**Post date:** [October 7, 2022, 1:00pm UTC](https://forum.bubble.io/t/how-to-create-a-function-in-bubble/227396/1 "2022-10-07T13:00:09Z")

</div>

Helo there, i am need help for calculate a time start and time end in my application, but i am have very dificult for manipulate this calc. So i have any idea for calculate this matematic operation by a function but i dont now how i create a function in bubble or if its possible.

Anyone know best practice to calc time or to create a function to do this.

thank you very much!

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [October 7, 2022, 1:03pm UTC](https://forum.bubble.io/t/how-to-create-a-function-in-bubble/227396/2 "2022-10-07T13:03:37Z")

</div>

Are you talking about JavaScript functions?..

Or are you just asking how to set start and end times in Bubble? (which is as simple as setting a field on a datatype, or setting a custom state value…)

---

<div class="post-metadata">

**Author:** ![jcleonis](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jcleonis/32/115531_2.png) [@jcleonis](https://forum.bubble.io/u/jcleonis)\
**Post date:** [October 7, 2022, 1:12pm UTC](https://forum.bubble.io/t/how-to-create-a-function-in-bubble/227396/3 "2022-10-07T13:12:08Z")

</div>

Its possible set a field only time? how i can do this?  
I need calc total time this fields. how i can do this?

I am a novice in bubble.

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [October 7, 2022, 4:40pm UTC](https://forum.bubble.io/t/how-to-create-a-function-in-bubble/227396/4 "2022-10-07T16:40:09Z")

</div>

I’m still not entirely sue I understand what you’re asking…

But, if you’re asking how to store a start time and end time, in order to track the time (like a time tracker app), then that’s very simple…

Just a time stamp for the start time, and a time stamp for the end time (in the DB or, if it’s just temporary in a custom state on the page).

Then calculate the difference, and display it in seconds (you can calculate minutes and hours from the seconds)…

You can then sum those times together if you have a list of them.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [December 16, 2022, 1:00pm UTC](https://forum.bubble.io/t/how-to-create-a-function-in-bubble/227396/5 "2022-12-16T13:00:13Z")

</div>

Closed on December 16, 2022, 1:00pm UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
