Time Widget Overlay for OBS

Switching all my StreamElements widgets to StreamerBot.

Looking for an elegant way to implement this (no C# code if possible). Yes, I saw Andilippi’s video: Creating A DATE & TIME Widget In STREAMERBOT

Similar to StreamElements Clock Widget by MrBoost, I want to implement a local time clock widget.

SAT 01 JUN 2024 12:33AM

And these formats would be nice.

Week: SUN, MON, TUE, WED, THU, FRI, SAT
Month: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC

Font: Uni Sans CAPS

There’s not a “get current time” sub-action so in order to do this you would have to use C#.

That being said, it’s only a couple of lines worth and Andi’s video that you linked gives you the jist of it. You can adjust the formatting based on how you’d like the information displayed (as seen in my example below).

DateTime dateTime = new DateTime.Now;
string formattedDate = dateTime.ToString("ddd dd MMM yyyy hh:mmtt").ToUpper();
CPH.SetArgument("currentDateTime", formattedDate);

Set your timed Action to update every minute (ensure you exclude it from your action history) and voila.

For your choice of font, as long as it’s installed on your computer, you can select it in OBS when you add it as a GDI Text source.

1 Like

Or just run a Timed Action with the %time% and %date% variables, formatted how you want, sent to a Set OBS GDI Text source and you can run it every second if you want to make sure the time stays up to date. No C# needed.

Date and Time are always available variables in SB afaik.

1 Like

I forgot those were always available, I thought they needed an action to run…even easier!

I’m still a newbie. I can’t get the format right.

Could you do that for me?

SAT 01 JUN 2024 12:33AM

Week: SUN, MON, TUE, WED, THU, FRI, SAT
Month: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC

I made 2 typos, but this works as you’d like it. Just Add an “Execute C#” sub-action and delete everything out of it and paste what’s below:

using System;

public class CPHInline
{
	public bool Execute()
	{
		DateTime dateTime = DateTime.Now;
		string formattedDate = dateTime.ToString("ddd dd MMM yyyy hh:mmtt").ToUpper();
		CPH.SetArgument("currentDateTime", formattedDate);
		return true;
	}
}

image

If you’d like to test/verify the formatting, you can do a Send Message subaction so it spits out in your chat and just put %currentDateTime% in the message box.

1 Like

Tried with broadcaster account. My chat shows %userDateTime%

Capture

I chose Save and Compile. I wonder what I’m doing wrong.

considering it should be %currentDateTime% as per my message above…that’s why you’re not seeing it in your message!

1 Like

I’m dumb. Thanks for the help. Worked :slight_smile: