Advanced Search

Results 1 to 2 of 2

Thread: Universal Countdown Script - Change date format?

  1. #1
    Join Date
    Jan 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Universal Countdown Script - Change date format?

    1) Script Title:
    Universal Countdown Script

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...lcountdown.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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,687
    Thanks
    43
    Thanked 3,129 Times in 3,095 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    //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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •