Skip to main content
This topic has been closed for replies.

6 replies

kglad
Community Expert
Community Expert
November 13, 2021

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)?

Gotta Dance
Inspiring
November 14, 2021

 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. 

kglad
Community Expert
Community Expert
November 15, 2021

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");
?>