Format Text (formatting numbers and dates)

How do I format a date or a number using blueprints?

For example in c# I can use string.Format(“{0:HH:mm}”, MyDateTime) to specify how I want the date to be formatted. Similarly, how do I format a float with leading zeros. “#0.00”?

HI Kev
You’ve got Time Seconds to String, which add leading zeros.

1 Like

Ah sorry re-read your post and I don’t think this helps because you need date

You can make a date time object and output that to text or string

2 Likes

Thanks for the help, but I’m looking for a way to specify the format of converted strings. The Format Text node is kind of what I was looking for, but I don’t think it allows you to specify how the value will appear after it is converted.

For example, lets say I have a float and I want it to appear in the format 0.00. I want the value of .354202 to appear as 0.35. Likewise if I have a datetime variable I want to format the date to YYYY-MM-DD. Sure, I can build the string the long way ,but I was just wondering if there is a built in format method.

Screenshot 2020-09-30 100638.jpg

Also, look into the datetime variables, they spit out all kind of goodness:

Screenshot 2020-09-30 100748.jpg

Then you can format it any way you need:

Screenshot 2020-09-30 101000.jpg

4 Likes

Hello Ashton_Audio, Thanks a trillion, the Time Seconds to String was never mentioned in any videos and adding it to my solution worked perfectly!

Just for anyone wondering, the node Everynone is showing converts large numbers to large numbers with commas (the ToText_(float)) node.

I was looking online for an easy solution, and people were saying all sorts of convoluted things, including using loops.

Nope. Not if I can help it.