PDA

View Full Version : Universal Countdown Script - Change date format?



Anders_II
01-30-2009, 08:26 AM
1) Script Title:
Universal Countdown Script

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex6/universalcountdown.htm

3) Describe problem:

Hi, I have just found this script and its just what I need but,
is there any chance that I can get this thing to work if I want to change the timeformat (see below):

This is the original code:
var servertimestring=(servermode=="server-php")? '<? print date("F d, Y H:i:s", time())?>' : (servermode=="server-ssi")? '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' : '<%= Now() %>'

But for "server-php" mode I would like to use the dateformat date("Y-m-d H:i:s") instead.

I have tried alot of changing the code but I get error (date will be NaN-Nan-Nan-...)

Can anyone help me?

Reguards
Anders

jscheuer1
01-30-2009, 06:03 PM
You cannot change the the format that the date is outputted from the server because the javascript Date() object needs it in that form, even if you could, it won't change how the date is displayed on your page. That is controlled here:


//1) Display countdown using plain text
function formatresults(){
if (this.timesup==false){//if target date/time not yet met
var displaystring="<span style='background-color: #CFEAFE'>"+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds</span> left until launch time"
}
else{ //else if target date/time met
var displaystring="Launch time!"
}
return displaystring
}

//2) Display countdown with a stylish LCD look, and display an alert on target date/time
function formatresults2(){
if (this.timesup==false){ //if target date/time not yet met
var displaystring="<span class='lcdstyle'>"+arguments[0]+" <sup>days</sup> "+arguments[1]+" <sup>hours</sup> "+arguments[2]+" <sup>minutes</sup> "+arguments[3]+" <sup>seconds</sup></span> left until launch time"
}
else{ //else if target date/time met
var displaystring="" //Don't display any text
alert("Launch time!") //Instead, perform a custom alert
}
return displaystring
}

see:


Q2) How do I customize the output or even behaviour of the countdown?

on the demo page for more info.