PDA

View Full Version : Date/Time Javascript or OpenTokens


chucklasker
04-11-06, 05:35 PM
Does anyone know of a Javascript or OpenToken code that would allow me to have a statement on a MM page that changes based on time of day AND day of week. I'd want one statement for weekdays before 4pm EST, one for weekdays after 4pm, and one for weekends.

I checked the usual Javascript sites with no luck for this level of specificity. There's a ton of clocks and date scripts, but no conditionals that take both into account that I could find. If anyone knows of one, I'd appreciate the link/code.

Vic - WolfPaw Computers
04-11-06, 05:46 PM
Chuck,

This might need some work, its untested but should be close:

%IF(s.dyn_tm_wday GT '0' AND s.dyn_tm_wday LT '6')%
%IF( '16','17,'18','19','20','21','22','23' CIN s.dyn_tm_hour)%
execute weekday after 4pm code
%ELSE%
execute weekday before 4pm code
%IFEND%
%IFEND%
%IF(s.dyn_tm_wday EQ '7' OR s.dyn_tm_wday EQ '0')%
%IF( '16','17,'18','19','20','21','22','23' CIN s.dyn_tm_hour)%
execute weekend after 4pm code
%ELSE%
execute weekend before 4pm code
%IFEND%
%IFEND%

chucklasker
04-11-06, 10:59 PM
Thanks, Vic. That got me on the right track. Here's what ended up working, which is almost exactly what you came up with:

%OUI%
%IF(%VAR(s.dyn_tm_wday)% GT '0' AND %VAR(s.dyn_tm_wday)% LT '6')%
%IF(('16' CIN %VAR(s.dyn_tm_hour)%) OR ('17' CIN %VAR(s.dyn_tm_hour)%) OR ('18' CIN %VAR(s.dyn_tm_hour)%) OR ('19' CIN %VAR(s.dyn_tm_hour)%) OR ('20' CIN %VAR(s.dyn_tm_hour)%) OR ('21' CIN %VAR(s.dyn_tm_hour)%) OR ('22' CIN %VAR(s.dyn_tm_hour)%) OR ('23' CIN %VAR(s.dyn_tm_hour)%))%
execute weekday after 4pm code
%ELSE%
execute weekday before 4pm code
%IFEND%
%ELSE%
execute weekend code
%IFEND%


As usual, you do man!

Vic - WolfPaw Computers
04-11-06, 11:00 PM
Yeah, I was looking for away to put all the after 4pm checks into one statement. I know it can be done - I just cannot recall the syntax.

Bruce - PhosphorMedia
04-11-06, 11:53 PM
Wouldn't:


%IF( (s.dyn_tm_wday GT 0) AND (s.dyn_tm_wday LT 6) AND (s.dyn_tm_hour GE 16)%


work?