Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di Bioboi
    Registrato dal
    Nov 1999
    Messaggi
    110

    Countdown con ore e minuti

    Come visualizzare anche i minuti restanti in questo script ?

    Cioè: nella pagina viene visualizzato "Mancano tot ore e tot minuti" all'evento.

    codice:
    <?php
    
    //CONFIGURE THE SCRIPT BELOW
    
    // The number of the month 1-12 that your event occurs
    $month=6;
    
    //The number of the day 1-31 that your event occurs
    $day=6;
    $hours=15;
    $minutes=0;
    $second=0;
    
    
    //The 4 diget number for the year that your event occurs
    $year=2009;
    
    //How would you like the countdown to display?
    // 1 = days
    // 2 = hours
    // 3 = minutes
    // 4 = seconds
    // default is to displa in days
    $display = 2;
    $display1 = 3;
    
    
    //DO NOT EDIT BELOW THIS LINE ----------------------
    // ------------------------------------------------
    
    $target = mktime($hours, $minutes, $seconds, $month, $day, $year);
    $today = time ();
    $difference =($target-$today);
    $minutes = (int) ($differenza/216000);
    if ($display == 1) { print ((int) ($difference/86400)) . " giorni"; }
    if ($display == 2) { print ((int) ($difference/3600)) . " ore"; }
    if ($display == 3) { print ((int) ($difference/60)) . " minuti"; }
    if ($display == 4) { print ((int) ($difference)) . " secondi"; }
    
    if ($display1 == 1) { print ((int) ($difference/86400)) . " giorni"; }
    if ($display1 == 2) { print ((int) ($difference/3600)) . " ore"; }
    if ($display1 == 3) { print ((int) ($difference/60)) . " minuti"; }
    if ($display1 == 4) { print ((int) ($difference)) . " secondi"; }
    
    ?>

  2. #2
    Lo script dice che esiste un evento il 6-6-2009 alle 15 in punto.
    Le variabili che dicono quante ore e quanti minuti mancano sono impostate in maniera corretta:

    $display = 2;
    $display1 = 3;

    Qual è il tuo problema? A parte che i nomi delle variabili a volte non coincidono
    $second => $seconds
    $difference => $differenza
    Oltretutto la riga
    $minutes = (int) ($difference/216000);
    è totalmente inutile

    Magari non hai ben capito come funziona lo script, in effetti avere due display ha poco senso (anche se dipende dall'utilizzo). Comunque $display ti dice quante ore mancano, $display1 ti dà la stessa informazione ma in minuti, magari a te interessava visualizzare quanti minuti mancano tolte le ore. A questo punto lo script che hai va modificato perchè non funziona come pensi.
    Se ti serve sapere solo ore e minuti al termine io farei questa modifica

    <?php

    //CONFIGURE THE SCRIPT BELOW

    // The number of the month 1-12 that your event occurs
    $month=6;

    //The number of the day 1-31 that your event occurs
    $day=6;
    $hours=15;
    $minutes=0;
    $seconds=0;


    //The 4 diget number for the year that your event occurs
    $year=2009;

    //DO NOT EDIT BELOW THIS LINE ----------------------
    // ------------------------------------------------

    $target = mktime($hours, $minutes, $seconds, $month, $day, $year);
    $today = time ();
    $difference =($target-$today);

    print ((int) ($difference/3600)) . " ore e ";
    print ((int) (($difference%3600)/60)) . " minuti";
    ?>

  3. #3
    Utente di HTML.it L'avatar di Bioboi
    Registrato dal
    Nov 1999
    Messaggi
    110
    Grazie!!! Gentilissimo!!!




Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.