Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Using php date as targetdate

  1. #1
    Join Date
    Mar 2008
    Posts
    9
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Using php date as targetdate

    1) Script Title: Universal Countdown

    2) Script URL (on DD):http://www.dynamicdrive.com/dynamici...lcountdown.htm

    3) Describe problem: how to i designate a mysql data field for targetdate, in other words i have end date/time stored in mysql database and would like to have it automatically inserted into targetdate ($targettime).

  2. #2
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Try echoing the date to the call
    Code:
    var launchdate=new cdLocalTime("cdcontainer", "server-php", 0, "<?php echo $targettime; ?>", "debugmode")
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    In general, the checklist for using any server side language to dynamically output client side JavaScripts is the same. As long as what gets output to the browser conforms to the syntax/ conventions of the client side script, as if you've manually added it to the page, it should work. In this case, it may look something like this:

    Code:
    var launchdate=new cdLocalTime("cdcontainer", "server-php", 0, <?echo $storedtime ?>, "debugmode")
    Assuming your pages are PHP enabled (.php), and $storedtime contains the full date/ time string you wish to count down to.

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Heh what Jas said in other words.

  5. #5
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Quote Originally Posted by ddadmin View Post
    Heh what Jas said in other words.
    It must be right when two people say it
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  6. #6
    Join Date
    Mar 2008
    Posts
    9
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Unhappy

    Quote Originally Posted by Jas View Post
    It must be right when two people say it
    I have tried both of the examples that where posted prior, but neither works. Script just gives me all NAN NAN etc.

    $dateclose is the timestamp from database.

    $targetdate = strftime("%A, %B %d, %Y %H:%M:%S %p", $date_close);

    var launchdate=new cdLocalTime("cdcontainer", "server-php", -60, "<?php echo $targetdate; ?>", "debugmode")

    Any other suggestions???

  7. #7
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Is your page properly PHP enabled? Please post a link to the page on your site that contains the problematic script so we can check it out.

  8. #8
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    In addition to having a PHP enabled server, the file also needs a .php extension (not .html) in order for it to go through the PHP parser.

    I would test it by just echoing the value of the variable to the body of the page to see if it works. If it does, make sure that it conforms to the date format needed in the JavaScript.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  9. The Following User Says Thank You to Jas For This Useful Post:

    penster1 (03-04-2008)

  10. #9
    Join Date
    Mar 2008
    Posts
    9
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Finally resolved problem!!
    Changed the following:
    $targetdate = strftime("%A, %B %d, %Y %H:%M:%S %p", $date_close);

    To This:
    $targetdate = strftime("%B %d, %Y %H:%M:%S", $date_close);

    Works Great.

    Now just need the page to redirect when timesup.

  11. #10
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    The script supports a function when the timer hits 0. To redirect, change:
    Code:
    else{ //else if target date/time met
    var displaystring="" //Don't display any text
    alert("Launch time!") //Instead, perform a custom alert
    }
    to:
    Code:
    else{
        var displaystring="";
        window.location="http://www.mysite.com";
    }
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  12. The Following User Says Thank You to Jas For This Useful Post:

    penster1 (03-04-2008)

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
  •