• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Passing a Datestamp into Animate

Engaged ,
Nov 12, 2021 Nov 12, 2021

Copy link to clipboard

Copied

Hi Adobe folks,

 

I'm trying to get Animate to retrieve the current date.

 

I found this doc from a collegue: https://helpx.adobe.com/ca/animate/using/html-publishing-templates.html

 

But nothing that discussed actual date/time. Is it possible to do this dynamically at all? 

Views

251

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
community guidelines
Community Expert ,
Nov 13, 2021 Nov 13, 2021

Copy link to clipboard

Copied

from where are you trying to retrieve the date/time?  the server that hosts the files (accurate, but requires server-side coding, eg php), or the users computer (inaccurate, but easier)?

Votes

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
community guidelines
Engaged ,
Nov 14, 2021 Nov 14, 2021

Copy link to clipboard

Copied

 Hi Kglad,

 

I have a dynamic situation involving banners. Hypothetically I have a movie release date and my banner needs to have a conditional message based on date. So like..

 

if date is 11/15, says "coming soon"

if date is 11/18 says "Playing Tomorrow!"

if date is 11/19 says " Playing tonight!"

if date is after 11/19 says "In Theatres Now"

 

So I need to get a datestamp into the timeline to tell it keyframe 1-4 based on the results of the date.

 

Is there something I can do to acheive this? Pulling from the server is probably preferred. I can probably using a publishing template if needed on the main HTML page, but whatever I can do to pass this variable would be great. 

 

Any advice appreciated. 

Votes

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
community guidelines
Community Expert ,
Nov 14, 2021 Nov 14, 2021

Copy link to clipboard

Copied

in your script panel:

 

var xmlhttp;

var domParser = new DOMParser();

//Parse the XML string into an XMLDocument object using
//the DOMParser.parseFromString() method.
//var xmlDocument = domParser.parseFromString(xmlString, "text/xml");
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

var xml_string = xmlhttp.responseText;
console.log(xml_string);
}
}

xmlhttp.open("GET", "./php/date.php", true);  // if date.php is in a php subfolder of the html file


// in the server-side date.php file in the php subfolder, use:


<?php
echo date("M-d-Y g:i A");
?>

Votes

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
community guidelines
LEGEND ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

"Pulling from the server is probably preferred."

 

Why? In 99.999% of cases the client-side date is going to be correct, and when it's not, it's just a banner ad, so who cares?

 

You can get the day and month in maybe five lines of JavaScript. And you're not "passing into" Animate, the Animate code would be retrieving it directly.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

 

Votes

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
community guidelines
Engaged ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

All of this is awesome, thanks so much guys!

Votes

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
community guidelines
Community Expert ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

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
community guidelines