Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

I think it is easier: How do I do greeting?

Avatar

Level 4

Hi.

I would like to know, what script I use to do greeting, for example:

If in the morning appear: "Good Morning".....

If in the night appear : Good Night.....

.. it continue..

I didn't get found out a script to get the current hour in number (in format 24hs). I think if I found out it, it's easiest, because I can use condition

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 10

The expression Num2Time(Time(), "A") will return either AM or PM.

Here is the complete code (FormCalc)

if (Num2Time(Time(), "A") == "AM") then

     xfa.host.messageBox("Good Morning")

else

     xfa.host.messageBox("Good Night")

endif

Nith

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

The expression Num2Time(Time(), "A") will return either AM or PM.

Here is the complete code (FormCalc)

if (Num2Time(Time(), "A") == "AM") then

     xfa.host.messageBox("Good Morning")

else

     xfa.host.messageBox("Good Night")

endif

Nith

Avatar

Level 4

Hi Nith, How are you?

Thanks for you reply, but is almost this.

I would like to want the function that would get the number hours in format Brazil (24). For example, I would like to greet also with a Good Afternoon.

I need just this function (i didn´t found out). I think with that I get to do what I want using condition

Sorry my bad English.

Avatar

Level 10

Try

if (Num2Time(time(), "HH", "pt_BR") < 12) then

     xfa.host.messageBox("Morning!")

else

     xfa.host.messageBox("Evening!")

endif

Avatar

Level 4

Hi.

Exactely this I was looking.

Thanks so much

Avatar

Level 4

Nith.

Thank you too.

I chose the Helpfull answer too!

See you.