# Creating a clock (12 hour clock)

**URL:** <https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524>\
**Category:** UI\
**Tags:** time, unreal-engine, day-night-cycle, Widget, Blueprint, question\
**Created:** [November 15, 2020, 11:50pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524 "2020-11-15T23:50:24Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChunkyCat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ChunkyCat](https://forums.unrealengine.com/u/ChunkyCat)\
**Post date:** [November 15, 2020, 11:50pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/1 "2020-11-15T23:50:24Z")

</div>

I am trying to solve my issue on creating a 12 hour clock (via widgets) however, the UE4 time clock goes from 0-12 for the day and 12-0 for the night. My issue is I want to implement an AM and PM as well as the 12 hour styled clock but am unable to due to the sky reusing 0-12 but backwards. I have provided a sketch of what I mean in order to clarify. The upper clock is how UE4 implemented its time while the lower section is how I would like to approach it. The following picture is a blueprint within the widget to show what I am trying to do and what I have done so far.

 ![322152-sketch.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/9/8/f9893103033ab4770e8816ed866ca066112d8561.png)

 ![322153-screenshot-2020-11-15-174836.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/3/e/f3edfbd882a0499cbc4c5a1eff3f2e1daf935185.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 16, 2020, 8:38am UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/2 "2020-11-16T08:38:31Z")

</div>

Which sky actor are you using?

---

<div class="post-metadata">

**Author:** ![ChunkyCat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ChunkyCat](https://forums.unrealengine.com/u/ChunkyCat)\
**Post date:** [November 16, 2020, 2:58pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/3 "2020-11-16T14:58:03Z")

</div>

I am using the GoodSky actor, I got it from the unreal asset store in the permanently free section.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 16, 2020, 3:25pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/4 "2020-11-16T15:25:55Z")

</div>

Good sky goes from 0 to 24. Do you want to make that AM and PM?

---

<div class="post-metadata">

**Author:** ![ChunkyCat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ChunkyCat](https://forums.unrealengine.com/u/ChunkyCat)\
**Post date:** [November 16, 2020, 3:30pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/5 "2020-11-16T15:30:25Z")

</div>

When you attach a directional lighting it goes from 0-12 and 12-0 (for night)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 16, 2020, 3:32pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/6 "2020-11-16T15:32:05Z")

</div>

Ok, then there’s no way to know if it’s AM or PM, unless you’re assuming it’s moving in sequence.

EDIT: Ok, you can tell if it’s AM or PM from the X rotation of the directional light.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 16, 2020, 4:01pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/7 "2020-11-16T16:01:38Z")

</div>

Like this ( this assumes you have set the rotation of the directional light to 0,0,0 ):

 ![322222-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/3/e/c3e14d03346d4f5d973437194d3366e3fc8e3f85.jpeg)

---

<div class="post-metadata">

**Author:** ![ChunkyCat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ChunkyCat](https://forums.unrealengine.com/u/ChunkyCat)\
**Post date:** [November 16, 2020, 6:00pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/8 "2020-11-16T18:00:53Z")

</div>

I noticed that you have the actor rotation set into float, how did you do that? whenever I summon get actor rotation I have the “rotation” type of variable instead of a “float” variable type. Here’s what I mean:

 ![322227-screenshot-2020-11-16-115853.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/2/9b2e94bbd23ab55c7017afa1e1f061c0bb3121bc.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 16, 2020, 6:04pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/9 "2020-11-16T18:04:29Z")

</div>

Right click on the pin and choose ‘break pin’.

---

<div class="post-metadata">

**Author:** ![ChunkyCat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ChunkyCat](https://forums.unrealengine.com/u/ChunkyCat)\
**Post date:** [November 16, 2020, 6:15pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/10 "2020-11-16T18:15:40Z")

</div>

Thanks! 😃 It works! How would you go about implementing the 12 hour styled clock? Like I mentioned before the float variables go from 0-12 for day and 12-0 for night. Is there a way to work with that?

EDIT: Nevermind, my only concern is that the floats go beyond the 4 digit limit for example instead of 10:30 its 10:29999999. Do you know how to fix that?

---

<div class="post-metadata">

**Author:** ![ChunkyCat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ChunkyCat](https://forums.unrealengine.com/u/ChunkyCat)\
**Post date:** [November 16, 2020, 6:44pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/11 "2020-11-16T18:44:08Z")

</div>

Hi again, you can ignore the previous concern points that I made since I kind of fixed them, but I just found a small problem. When the Time switches from AM to PM the time goes from 11 to 0. Is there a way to somehow show a 12 instead of a 0? Thanks again!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 16, 2020, 7:30pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/12 "2020-11-16T19:30:51Z")

</div>

It’s getting a bit messy, but:

 ![322235-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/9/6/396504a1ae07c22b3c82356035a6bafe43efb00c.jpeg)

---

<div class="post-metadata">

**Author:** ![ChunkyCat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ChunkyCat](https://forums.unrealengine.com/u/ChunkyCat)\
**Post date:** [November 16, 2020, 7:44pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/13 "2020-11-16T19:44:25Z")

</div>

Yes! Thank you!! This is exactly what I needed!

---

<div class="post-metadata">

**Author:** ![dgnsparta](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dgnsparta](https://forums.unrealengine.com/u/dgnsparta)\
**Post date:** [July 12, 2022, 12:40pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/14 "2022-07-12T12:40:52Z")

</div>

Hello. Can you share all the codes about a.m and p.m clock?

---

<div class="post-metadata">

**Author:** ![ChunkyCat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ChunkyCat](https://forums.unrealengine.com/u/ChunkyCat)\
**Post date:** [July 21, 2022, 6:13pm UTC](https://forums.unrealengine.com/t/creating-a-clock-12-hour-clock/474524/15 "2022-07-21T18:13:19Z")

</div>

Here it is: [Clock System (AM-PM Mode) posted by anonymous | blueprintUE | PasteBin For Unreal Engine](https://blueprintue.com/blueprint/7m7q1u30/)
