# Elapsed milliseconds since start of level

**URL:** <https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782>\
**Category:** C++\
**Tags:** unreal-engine, level, question, CPP\
**Created:** [February 2, 2015, 7:09pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782 "2015-02-02T19:09:04Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![etbh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@etbh](https://forums.unrealengine.com/u/etbh)\
**Post date:** [February 2, 2015, 7:09pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/1 "2015-02-02T19:09:04Z")

</div>

I need to get the time in milliseconds elapsed since the start of the level.  
`AGameState::ElapsedTime` seems to be what I’m looking for, except it delivers a time in seconds.

Is there a way to access to this in a more simple way than managing a global-ish timer as a chronometer?

---

<div class="post-metadata">

**Author:** ![MickD777](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MickD777](https://forums.unrealengine.com/u/MickD777)\
**Post date:** [February 2, 2015, 9:10pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/2 "2015-02-02T21:10:18Z")

</div>

Yes, you can use the following :

```
float realtimeSeconds = UGameplayStatics::GetRealTimeSeconds(());

```

Basically, the UGameplayStatics class contains lots of neat stuff, and 2 or 3 other useful function regarding time.

If you want to get that in hours/minutes/seconds, you can use the FTimespan structure.

You can initialiaze the struct like so :

```
FTimespan timeSpan = FTimespan(/*Hours*/0,/*Minutes*/0, realtimeSeconds /*Seconds*/);

```

Then you can use that struct to extract the time the way you want.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![MickD777](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MickD777](https://forums.unrealengine.com/u/MickD777)\
**Post date:** [February 16, 2015, 2:23am UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/3 "2015-02-16T02:23:39Z")

</div>

Did my answer help you out?

---

<div class="post-metadata">

**Author:** ![MorskoyZmey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MorskoyZmey](https://forums.unrealengine.com/u/MorskoyZmey)\
**Post date:** [September 21, 2015, 8:18pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/4 "2015-09-21T20:18:35Z")

</div>

Also you can use

```
FPlatformTime::Seconds();

```

It returns at least milliseconds at last microseconds

---

<div class="post-metadata">

**Author:** ![StAnger](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@StAnger](https://forums.unrealengine.com/u/StAnger)\
**Post date:** [April 15, 2018, 6:26pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/5 "2018-04-15T18:26:23Z")

</div>

Either way it helped me so thanks 😃

---

<div class="post-metadata">

**Author:** ![MickD777](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MickD777](https://forums.unrealengine.com/u/MickD777)\
**Post date:** [April 19, 2018, 3:50pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/6 "2018-04-19T15:50:23Z")

</div>

Yeah, even 3 years later 😃

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [April 20, 2018, 7:26am UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/7 "2018-04-20T07:26:40Z")

</div>

you can do it cleaner with `FTimespan::FromSeconds(realtimeSeconds);`

---

<div class="post-metadata">

**Author:** ![Compguy321](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Compguy321](https://forums.unrealengine.com/u/Compguy321)\
**Post date:** [July 28, 2018, 12:00am UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/8 "2018-07-28T00:00:11Z")

</div>

Is there a way to do this in Blueprint?

---

<div class="post-metadata">

**Author:** ![MorskoyZmey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MorskoyZmey](https://forums.unrealengine.com/u/MorskoyZmey)\
**Post date:** [July 30, 2018, 12:51pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/9 "2018-07-30T12:51:22Z")

</div>

Sure [Get Real Time Seconds | Unreal Engine Documentation](https://api.unrealengine.com/INT/BlueprintAPI/Utilities/Time/GetRealTimeSeconds/index.html)

---

<div class="post-metadata">

**Author:** ![MorskoyZmey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MorskoyZmey](https://forums.unrealengine.com/u/MorskoyZmey)\
**Post date:** [July 30, 2018, 12:55pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/10 "2018-07-30T12:55:03Z")

</div>

Also there is another way to do the same `()->GetRealTimeSeconds();`. Note, that returning value is equal to such of Time node in Materials! (but check Ignore Pause in Time node!) Can be used to control animations without triggering parameters every single tick.

---

<div class="post-metadata">

**Author:** ![PragmaticSystematic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pragmaticsystematic/32/88709_2.png) [@PragmaticSystematic](https://forums.unrealengine.com/u/PragmaticSystematic)\
**Post date:** [August 8, 2021, 7:51am UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/11 "2021-08-08T07:51:25Z")

</div>

This is in seconds, not in miliseconds.

---

<div class="post-metadata">

**Author:** ![Gulith421](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gulith421](https://forums.unrealengine.com/u/Gulith421)\
**Post date:** [October 25, 2022, 11:47am UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/13 "2022-10-25T11:47:22Z")

</div>

it returns a float, so you just x1000 to get milliseconds

---

<div class="post-metadata">

**Author:** ![Barracius12](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/barracius12/32/737612_2.png) [@Barracius12](https://forums.unrealengine.com/u/Barracius12)\
**Post date:** [November 25, 2022, 4:33pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/14 "2022-11-25T16:33:23Z")

</div>

That would advance the time by the thousands and not in-between.

1000-\>2000-\>3000-\>etc

While what OP wants is to have the values in-between too

---

<div class="post-metadata">

**Author:** ![Gulith421](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gulith421](https://forums.unrealengine.com/u/Gulith421)\
**Post date:** [November 25, 2022, 5:17pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/15 "2022-11-25T17:17:54Z")

</div>

getRealTimeSeconds return a value in float:  
1,40654 seconde  
so if you multiply by 1000, you get 1406 milliseconds, not 1000.

---

<div class="post-metadata">

**Author:** ![UnGamerValluno](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnGamerValluno](https://forums.unrealengine.com/u/UnGamerValluno)\
**Post date:** [September 23, 2024, 2:54pm UTC](https://forums.unrealengine.com/t/elapsed-milliseconds-since-start-of-level/305782/16 "2024-09-23T14:54:50Z")

</div>

Thank you, this was super helpful. I also used the FTimespan::ToString(format) method like this:

```auto
float GameTime = UGameplayStatics::GetRealTimeSeconds(GetWorld());
FTimespan TimeSpan = FTimespan(0, 0, GameTime);
return TimeSpan.ToString(TEXT("%m:%s"));

```

Just leaving it here as an additional note because it took me a while to figure out how to use the formatting options. Basically what I was missing is that the expected TCHAR\* is generated by the TEXT macro.
