Within Business Hours or Not Within

Within Business Hours or Not Within

We need to idenify when a form was submitted on our website.  The date/time.  We then need to take it a step further in identifing whether or not the form fill out was within our business hours..  If it was not within our business hours we are looking to send an auto-reply email letting them know they will be contacted when business hours resume. 

I know how to accomplish the form fill out date/time with creating a date/time field called "Filled out Form On" and have it be populated by the {{system.datetime}} token.  I am struggling on how to identify whether or not it was within business hours.

Does anyone have any input on how to accomplish such a process? 

Thank you!

9 Comments
SanfordWhiteman
Level 10 - Community Moderator
Post a hidden form field that contains true/false for whether the browser's (UTC) time is within your (UTC) business hours.  
Anonymous
Not applicable
Sanford's solution is pretty good. 

You could also use a webhook to read the date/time, determine if it's in/out of business hours and update the MKTO record accordingly. 

 
Nate_Oosterhous
Level 7
Hi Sanford,

Could you provide a little more detail on how to accomplish something like that?  How does the hidden form field know grab the time and check if it is within our business hours?

Thanks
Anonymous
Not applicable
I believe he was suggesting you could use Javascript to grab the time from the browser and write more javascript to set the hidden 'office hours' field to 'in' or 'out'
SanfordWhiteman
Level 10 - Community Moderator
@Nate O I'll post a demo this evening. Gotta run to some meetings.

@Mark P Don't make it seem like so much code!  Probably a one-liner. 🙂
SanfordWhiteman
Level 10 - Community Moderator
Demo of checking current time on the server (i.e. at your company, not actually on Marketo's server) at the time the form is submitted and setting hidden field accordingly: http://codepen.io/figureone/pen/oXgRme?editors=001

For the purposes of this demo business hours start at 9:00 (0900) and end at 5:00 (1700).  Thus at 5:00 exactly you are considered home for the day.
Anonymous
Not applicable
 @Sanford  Nice one!  Thanks for sharing, this is great!
SanfordWhiteman
Level 10 - Community Moderator
Glad you like it man! I like the challenges this forum puts out there.  Working with company opening hours (which are of course in local time) from the browser is a kind of fascinating task. Browsers themselves offer no facility to work with time zones other than the computer's local time zone. ? So without at least some kind of third-party code there is truly no way to know "What time is it there?" You're left with 2 choices: code like moment-timezone.js that actually includes the entire timezone database from 2010-2020 and loads it into the browser, or an API like the tzdb that I used here. If you use the download method it's a heavierweight call, and even though it's cacheable that won't help on the person's first form fillout.
kh-lschutte
Community Manager
Status changed to: Open Ideas