# How to convert Game time Format to 00:00:00

**URL:** <https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845>\
**Category:** UI\
**Tags:** hud, timer, unreal-engine, question\
**Created:** [August 1, 2014, 8:40am UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845 "2014-08-01T08:40:37Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![C-Arch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@C-Arch](https://forums.unrealengine.com/u/C-Arch)\
**Post date:** [August 1, 2014, 8:40am UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/1 "2014-08-01T08:40:37Z")

</div>

Hi.

Anyone have an idea how to set the gametime to a 00:00:00 format  
Basically i want it to be 00:01:08 indicating 1 minute 8 seconds.

Right now it outputs as 1.8  
I tried various ways of doing this but none of them does what i want.  
The only solution i do have is a very long a tedious and unpractical way of comparing every second.

Compare INT if equal to 1 set String to 01, If INT 2 Set String to 02 etc.

Im sure there is an easier way. Just haven’t found it yet.

My HUD is configured to print it correctly. I just need the correct format

---

<div class="post-metadata">

**Author:** ![Dieselhead](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dieselhead](https://forums.unrealengine.com/u/Dieselhead)\
**Post date:** [August 1, 2014, 9:01am UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/2 "2014-08-01T09:01:16Z")

</div>

You can get the seconds by using Modulo. In code you would use the % sign.

```
float seconds = GameTimeInSeconds % 60; // 60 because there are 60 seconds in a minute

```

The way it works is it will remove 60 (or whatever you use) from GameTimeInSeconds until there’s less then 60 left. It will then return whatever is left. In this case you remove one minute at a time until there’s less then a minute left, and the result is the remaining seconds.

You get the minutes by dividing by 60 and flooring the value.  
You get the hours by dividing by (60_60) which is 3600, and flooring the value.  
You can get days by dividing by (60_60\*24) and flooring the value.

 ![11663-h-m-s.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/c/44cefb89b61cdcedfedb0167bf786d9b96642589.png)

---

<div class="post-metadata">

**Author:** ![C-Arch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@C-Arch](https://forums.unrealengine.com/u/C-Arch)\
**Post date:** [August 1, 2014, 9:30am UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/3 "2014-08-01T09:30:48Z")

</div>

Ahh thx i learned something new.  
However it still does not add a 0 in front of seconds. It will still be 1,2,3 and not 01,02,03.

---

<div class="post-metadata">

**Author:** ![Dieselhead](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dieselhead](https://forums.unrealengine.com/u/Dieselhead)\
**Post date:** [August 1, 2014, 9:52am UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/4 "2014-08-01T09:52:10Z")

</div>

Sorry, how about this? I switched the variables to Ints as it was printing it with decimals.

 ![11665-h-m-s2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/4/d/d4d4cc38a8227c7f5290e4ffef3e035c9691dd10.png)

---

<div class="post-metadata">

**Author:** ![C-Arch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@C-Arch](https://forums.unrealengine.com/u/C-Arch)\
**Post date:** [August 1, 2014, 10:05am UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/5 "2014-08-01T10:05:00Z")

</div>

Thx a million dude. The get substring is what i was looking for. Does exactly what i needed.

So you solved the issue i was having and an issue i was going to have with the % modulus tip. Thx again.

---

<div class="post-metadata">

**Author:** ![C-Arch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@C-Arch](https://forums.unrealengine.com/u/C-Arch)\
**Post date:** [August 8, 2014, 4:54am UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/6 "2014-08-08T04:54:11Z")

</div>

@Dieselhead

How do i mark your answer as the answer?

---

<div class="post-metadata">

**Author:** ![DaveHall17](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DaveHall17](https://forums.unrealengine.com/u/DaveHall17)\
**Post date:** [April 12, 2016, 4:05pm UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/7 "2016-04-12T16:05:56Z")

</div>

Thanks for this answer I found it really useful . Do you know if it is possible to calculate milliseconds as well ?

---

<div class="post-metadata">

**Author:** ![Divo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Divo](https://forums.unrealengine.com/u/Divo)\
**Post date:** [April 4, 2017, 1:40pm UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/8 "2017-04-04T13:40:59Z")

</div>

Stumbled across your post while I was trying to do something similar.  
I figured out a great way to do it that doesn’t require a lot of effort! 🙂

 ![132825-timespan.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/8/3/c83d74ba6a0daefd8dad403be15aed982e12592a.png)

---

<div class="post-metadata">

**Author:** ![CatClicli](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CatClicli](https://forums.unrealengine.com/u/CatClicli)\
**Post date:** [February 23, 2018, 11:26am UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/9 "2018-02-23T11:26:33Z")

</div>

This answer is outdated. ue4 has FormatText and ToText advanced settings have minimum number of digits now. See @Divo’s answer.

---

<div class="post-metadata">

**Author:** ![chiefGui](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chiefgui/32/612858_2.png) [@chiefGui](https://forums.unrealengine.com/u/chiefGui)\
**Post date:** [June 15, 2018, 6:33pm UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/10 "2018-06-15T18:33:17Z")

</div>

Thank you @Divo! You saved the day!

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [March 1, 2019, 5:42pm UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/11 "2019-03-01T17:42:22Z")

</div>

If you only need (minutes:seconds:milliseconds), I have created a custom actor component that will output this format automatically. Simply add the component to any blueprint you want and call the function. Everything else is taken care of under the hood. Code is all “copy/paste” to be blueprint user friendly. If you need hours as well feel free to modify the code, it shouldn’t be too difficult.

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/d/4/cd4f45ee0af5e582bfbbee94c9cd80b4454edae2.jpeg "Unreal Engine 4 Tutorial: Stop Watch/Racing Timer Node #UE4 #race #laptime") ](https://www.youtube.com/watch?v=dDDHtSp_A-0)

---

<div class="post-metadata">

**Author:** ![Ahmedinski](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ahmedinski](https://forums.unrealengine.com/u/Ahmedinski)\
**Post date:** [September 22, 2023, 1:02am UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/12 "2023-09-22T01:02:28Z")

</div>

lol, you are the real mvp

---

<div class="post-metadata">

**Author:** ![justmakes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@justmakes](https://forums.unrealengine.com/u/justmakes)\
**Post date:** [December 7, 2024, 5:08pm UTC](https://forums.unrealengine.com/t/how-to-convert-game-time-format-to-0000/289845/13 "2024-12-07T17:08:03Z")

</div>

i realised with this setup that the minutes carry on past 60, you need one of those % nodes between divide and floor for the minutes.
