Foren Foren

Zurück

Day of the Week

Umschalten
Day of the Week
Antwort
23.03.22 19:13
Hello Team!  
I've been able to pull dates and times into my lessons, but I'd like to know if there is any way of pulling the day of the week.  Is this something that is possible? 
Thanks! 
Scott
0 (0 Stimmen)

RE: Day of the Week
Antwort
23.03.22 20:44 als Antwort auf Scott Sheridan.
Hi Scott,
How are you pulling in the date? With the built-in registered function, or via an IFrame? This might help: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_date_weekday

Let us know the exact format that you're after (and is it today's day?), and how you're currently getting the date, and we can help guide you.

- Nav
0 (0 Stimmen)

RE: Day of the Week
Antwort
24.03.22 13:19 als Antwort auf Navdeep Dhillon.
Hi Nav, 
I worked with John on something else a few weeks ago where we pulled the date and time in MM/DD/YYYY HH:MM format using the blocks below (they have been modified a bit to fit what I'm doing).

At the moment I'm working on a project where a user needs to access their calendar and was hoping to have the actual day of the week show up.  If I wanted to go with the code provided above, how would I go about doing that?

Thanks, 
Scott
0 (0 Stimmen)

RE: Day of the Week
Antwort
24.03.22 19:45 als Antwort auf Scott Sheridan.
Hi Scott,
I don't think the weekday is part of the built in getTime function. We'll have to check with the dev team if it is.

Instead, you can define your own javascript function. There's two ways to do this - one is by registering your own custom function, and one is to use an IFrame. We'll go with the IFrame approach since this custom javascript is pretty limited in scope. And with the IFrame, you can set it and forget it. FYI, SmartBuilder calls an IFrame a "Web Object" - I use the terms interchangeably.

Check out the attached lesson and image - it should even work in Preview. You can copy the Wrb Object into your lesson, and the javascript inside should come with it (you can make it smaller and hide it offscreen - it still needs to Start Visible, though). Then create a similar action from the Web Object block to set your variable. Keep in mind that "onPageLoad" as a trigger might happen before the Web Object has a chance to load, so we're using "Web Object.onShow". The blue "get data" block comes from the Web Object's flyout panel.

That ought to do it! Let us know if you have any questions.
0 (0 Stimmen)

RE: Day of the Week
Antwort
25.03.22 13:40 als Antwort auf Navdeep Dhillon.
That's great! Thanks very much, Nav. 
Scott
0 (0 Stimmen)