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?
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)?
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.
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");
?>
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
Copy link to clipboard
Copied
All of this is awesome, thanks so much guys!
Copy link to clipboard
Copied
you're welcome.