Blockly AktuelleZeit als SS:mm

Is there is block to get the current time in a user defined format ?

You can get the time with now-block and then create these strings Date-String but your not completely free in the format.

But when you look at the code, it generates the following for you

(zdt.now()).format(dtf.ofPattern(‘yyyy-MM-dd’));

So what you could do is use the inline-script-block and manually create that little snippet youself with the wanted pattern.

Does that help?

1 Like

Thanks, I couldn’t figure that out as well and went with hour and minutes of … but this gives you a number. So this would be 7:3 if it’s 07:03 which needs more formatting.

(zdt.now()).format(dtf.ofPattern(‘HH:mm’));

works. Thanks again.

Works pefectly. Only issue is size of inline box. This is far to small. So it is very hard ti edit the text.

I know but I haven’t found any way to (re)size the box in the past where I have seen the same, though I tried just now with the latest blockly version on 3.4.x:

image

Does it look different on your side. Can you show meyour block with some blocks around, so I can try to reproduce it?

Maybe I’ll add something like “with Pattern” (and input box) to that Block in 4.0 :wink:

image

Would you like that?

1 Like

Definitely! That would be perfect.

Is this the same topic?