Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Get Time Parting Plugin Replication in DTM

Avatar

Avatar
Level 1
bhavin_shah1
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
bhavin_shah1
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
bhavin_shah1
Level 1

15-10-2015

Hi 

I'm trying to recreate the time parting plugin in DTM using data elements

The idea is to use the JS DOM date() function to populate a ever/prop and then to use the rule classification to split the string into the components ( saving me 3 variables)

i'm not a java script expert so but I've managed to get window.Date() to return back the value I want,

When I load window.Date as a jsobject in Data Elements it returns function Date() { [native code] }

Any help on this or Is there a better way to achieve this?

Thanks

Bhavin

Replies

Avatar

Avatar
Validate 1
Level 2
michael_johns_6
Level 2

Likes

0 likes

Total Posts

19 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
michael_johns_6
Level 2

Likes

0 likes

Total Posts

19 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Affirm 1
View profile
michael_johns_6
Level 2

15-10-2015

You can use something like this as a custom script for your data element.

 

return (function () { "use strict"; var now = new Date(); var year = "" + now.getFullYear(); var month = "" + (now.getMonth() + 1); if (month.length == 1) { month = "0" + month; } var day = "" + now.getDate(); if (day.length == 1) { day = "0" + day; } var hour = "" + now.getHours(); if (hour.length == 1) { hour = "0" + hour; } return year + "-" + month + "-" + day + " " + hour; })();

Avatar

Avatar
Validate 1
Level 1
garry_przyklenk
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
garry_przyklenk
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
garry_przyklenk
Level 1

15-10-2015

var dt = new Date(); var day, hour, minutes, daytype; if (dt.getDay() == "0") { day = "Sunday"; daytype = "Weekend"; } else if { (dt.getDay() == "1") { day = "Monday"; daytype = "Weekday"; } else if { (dt.getDay() == "2") { day = "Tuesday"; daytype = "Weekday"; } else if { (dt.getDay() == "3") { day = "Wednesday"; daytype = "Weekday"; } else if { (dt.getDay() == "4") { day = "Thursday"; daytype = "Weekday"; } else if { (dt.getDay() == "5") { day = "Friday"; daytype = "Weekday"; } else if { (dt.getDay() == "6") { day = "Saturday"; daytype = "Weekend"; } var time = daytype + ":" + day + ":" + dt.getHours() + ":" + dt.getMinutes(); return(time);

Once you have the output of this data element (call it whatever, I called mine "Day and Time") you can setup a classification rule builder entry to break it up into Weekday/Weekend, Day of the Week, and Hour of the Day.  I didn't bother breaking up hour of the day by every 30 minute interval, but whatever, you could if you like.  I also didn't put in AM/PM, because I hated that for the longest time, makes it really hard to sort nicely.