Highlighted

Dynamically Insert Date in HTML5 Canvas Ad

New Here ,
Sep 24, 2020

Copy link to clipboard

Copied

I would like to create a display ad where the date displayed in the ad changes each day to: todays date +14 weeks.

 

I would also to be able to contol what element of the date I insert where, eg I will insert month in one place and date in another - see screenshot

 

Any ideas on the best way to achieve this?

 

Thanks!

TOPICS
Ad development, Code, How to, Other, Performance

Views

72

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Dynamically Insert Date in HTML5 Canvas Ad

New Here ,
Sep 24, 2020

Copy link to clipboard

Copied

I would like to create a display ad where the date displayed in the ad changes each day to: todays date +14 weeks.

 

I would also to be able to contol what element of the date I insert where, eg I will insert month in one place and date in another - see screenshot

 

Any ideas on the best way to achieve this?

 

Thanks!

TOPICS
Ad development, Code, How to, Other, Performance

Views

73

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 24, 2020 0
Adobe Community Professional ,
Sep 25, 2020

Copy link to clipboard

Copied

use a dynamic textfield and the javascript Date() reference for the users date/time (which is so-so for accuracy), https://www.w3schools.com/jsref/jsref_obj_date.asp

 

eg,

 

this.tf.text = new Date();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 25, 2020 1
New Here ,
Oct 05, 2020

Copy link to clipboard

Copied

I also needed the date to be in the future (and the month to be in name format) - figured it out as follows: Just added as custom javascript:

 

var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";

var d = new Date();
var numberOfDaysToAdd = 98;
d.setDate(d.getDate() + numberOfDaysToAdd);

var n = month[d.getMonth()];

document.getElementById("month").innerHTML = n;

document.getElementById("day").innerHTML = d.getDate();

 

<p id="month"></p>
<p id="day"></p>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 05, 2020 0