Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    Calendario, togliere i minuti e i secondi

    Ciao a tutti,
    cercando sul formu ho trovato il link a un calenderio che faceva al caso mio, ecco il link http://javascriptkit.com/script/script2/timestamp.shtml

    Il fatto è che non quando clicco su una data del calendario mi da anche i minuti e i secondi.
    Come posso fare in modo che mi dia solo la data, possibilmente divisa da "/" e non da "-", senza i9 minuti e i secondi??
    Grazie
    spider

  2. #2
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    Ciao spider81man,

    ho fatto anche io un calendario simile (senza ora e con "/" come separatore)
    guarda qua se può andarti bene

  3. #3
    Guarda il codice è molto lungo.
    CMQ provo ma se avete qualcosa d+ "chiaro" sarebbe meglio.
    Grazie
    spdier

  4. #4
    Il tuo stesso problema lo avevo io qualche giorno fa... dopo ORE VVoVe: di studio sono riuscito a farcela: ecco qua il codice:
    Codice PHP:
    // Title: Timestamp picker
    // Description: See the demo at url
    // URL: [url]http://us.geocities.com/tspicker/[/url]
    // Script featured on: [url]http://javascriptkit.com/script/script2/timestamp.shtml[/url]
    // Version: 1.0
    // Date: 12-05-2001 (mm-dd-yyyy)
    // Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
    // Notes: Permission given to use this script in any kind of applications if
    //    header lines are left unchanged. Feel free to contact the author
    //    for feature requests and/or donations

    function show_calendar(str_targetstr_datetime) {
     var 
    arr_months = ["Gennaio""Febbraio""Marzo""Aprile""Maggio""Giugno",
                       
    "Luglio""Agosto""Settembre""Ottobre""Novembre""Dicembre"];
     var 
    week_days = ["Do""Lu""Ma""Me""Gi""Ve""Sa"];
     var 
    n_weekstart 1// day week starts from (normally 0 or 1)
     
    var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
     var 
    dt_prev_month = new Date(dt_datetime);
     
    dt_prev_month.setMonth(dt_datetime.getMonth()-1);
     var 
    dt_next_month = new Date(dt_datetime);
     
    dt_next_month.setMonth(dt_datetime.getMonth()+1);
     var 
    dt_firstday = new Date(dt_datetime);
     
    dt_firstday.setDate(1);
     
    dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
     var 
    dt_lastday = new Date(dt_next_month);
     
    dt_lastday.setDate(0);
     
    // html generation (feel free to tune it for your particular application)
     // print calendar header
    /* Questo è il link originario (se si vuole riaggiungere l'ora)
    "<a href=\"javascript:window.opener."+str_target+".value='"+dt2dtstr(dt_current_day)+"+document.cal.time.value'; window.close();\">"+
    */
     
    var str_buffer = new String (
         
    "<html>\n"+
          
    "<head>\n"+
           
    "<title>Eventi</title>\n"+
          
    "</head>\n"+
          
    "<body bgcolor='Black'>\n"+
           
    "<table class='clsOTable' cellspacing='0' border='0' width='100%'>\n"+
            
    "<tr>\n"+
             
    "<td bgcolor='#4D4D4D'>\n"+
              
    "<table cellspacing='1' cellpadding='3' border='0' width='100%'>\n"+
               
    "<tr>\n"+
                
    "<td bgcolor='#4D4D4D'>"+
                   
    "<a href=\"javascript:window.opener.show_calendar('"+
                       
    str_target+"', '"dt2dtstr(dt_prev_month)+"');\">"+  //+document.cal.time.value
                     
    "[img]immagini/prev.gif[/img]</a>\n"+
                
    "</td>\n"+
                
    "<td bgcolor='#4D4D4D' colspan='5' align='center'>"+
                  
    "<font color='white' face='tahoma, verdana' size='2'>"
                         
    +arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+
                  
    "</font>\n"+
                
    "</td>\n"+
                
    "<td bgcolor='#4D4D4D' align='right'>"+
                    
    "<a href=\"javascript:window.opener.show_calendar('"
                        
    +str_target+"', '"+dt2dtstr(dt_next_month)+"');\">"+  //+document.cal.time.value
                      
    "[img]immagini/next.gif[/img]</a>\n"+
                
    "</td>\n"+
               
    "</tr>\n"
         
    );
     var 
    dt_current_day = new Date(dt_firstday);
     
    // print weekdays titles
     
    str_buffer += "<tr>\n";
     for (var 
    n=0n<7n++)
         
    str_buffer += "    <td bgcolor='#888888'>"+
                    
    "<font color='white' face='tahoma, verdana' size='2'>"+
                    
    week_days[(n_weekstart+n)%7]+"</font></td>\n";
         
    // print calendar table
         
    str_buffer += "</tr>\n";
         while (
    dt_current_day.getMonth() == dt_datetime.getMonth() ||
                
    dt_current_day.getMonth() == dt_firstday.getMonth()) {
            
    // print row heder
            
    str_buffer += "<tr>\n";
            for (var 
    n_current_wday=0n_current_wday<7n_current_wday++) {
                if (
    dt_current_day.getDate() == dt_datetime.getDate() &&
                    
    dt_current_day.getMonth() == dt_datetime.getMonth())
                  
    // print current date
                  
    str_buffer += "    <td bgcolor='#0099FF' align='right'>";
                else if (
    dt_current_day.getDay() == || dt_current_day.getDay() == 6)
                       
    // weekend days
                       
    str_buffer += "    <td bgcolor='#D5D5D5' align='right'>";
                     else
                       
    // print working days of current month
                       
    str_buffer += "    <td bgcolor='white' align='right'>";
                if (
    dt_current_day.getMonth() == dt_datetime.getMonth())
                  
    // print days of current month
                  
    str_buffer += "<a href=\"javascript:window.opener."+str_target+
                             
    ".value='"+dt2dtstr(dt_current_day)+"'; window.close();\">"//+document.cal.time.value
                             
    "<font color='black' face='tahoma, verdana' size='2'>";
                else
                  
    // print days of other months
                  
    str_buffer += "<a href=\"javascript:window.opener."+str_target+
                             
    ".value='"+dt2dtstr(dt_current_day)+"'; window.close();\">"//+document.cal.time.value
                             
    "<font color='gray' face='tahoma, verdana' size='2'>";
                  
    str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
                  
    dt_current_day.setDate(dt_current_day.getDate()+1);
            }
          
    // print row footer
          
    str_buffer += "</tr>\n";
         }
        
    // print calendar footer
        
    str_buffer +=
    /* Il form eliminato qua sotto inserisce l'orario nella tabella. E' però necessario
       reinserire anche gli altri pezzi tagliati!*/
    /*            "<form name='cal'>\n<tr><td colspan='7' bgcolor='#888888'>"+
                  "<font color='White' face='tahoma, verdana' size='2'>"+
                  "Ora: <input type='text' name='time' value='"+dt2tmstr(dt_datetime)+
                  "' size='8' maxlength='8'></font></td></tr>\n</form>\n" +  */
                  
    "</table>\n" +
                  
    "</tr>\n</td>\n</table>\n" +
                  
    "</body>\n" +
                  
    "</html>\n";
        var 
    vWinCal window.open("""Eventi",
                    
    "width=200,height=205,status=no,resizable=yes,top=250,left=400");
        
    vWinCal.opener self;
        var 
    calc_doc vWinCal.document;
        
    calc_doc.write (str_buffer);
        
    calc_doc.close();
     }
    // datetime parsing and formatting routimes. modify them if you wish other datetime format
    function str2dt (str_datetime) {
            
    // Sostituire re_date per tornare al vecchio formato con l'ora!
        
    var re_date = /^(\d+)\-(\d+)\-(\d+)$/; //var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;
        
    if (!re_date.exec(str_datetime))
            return 
    alert("Invalid Datetime format: "str_datetime);
        return (new 
    Date (RegExp.$3RegExp.$2-1RegExp.$1RegExp.$4RegExp.$5RegExp.$6));
    }
    function 
    dt2dtstr (dt_datetime) {
        return (new 
    String (                                               // E' necessario aggiungere lo spazio finale
                
    dt_datetime.getDate()+"/"+(dt_datetime.getMonth()+1)+"/"+dt_datetime.getFullYear())); //+" "));
    }
    function 
    dt2tmstr (dt_datetime) {
        return (new 
    String (
                
    dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));

    Ho aggiunto un paio di note delle cose eliminate (che ho solo commentato.

    Ho fatto in modo che l'ora si veda lo stesso, ma che non appaia nel campo di testo e ti ho anche già cambiato il formato g/m/a


  5. #5
    Utente di HTML.it L'avatar di pyotrex
    Registrato dal
    Feb 2003
    Messaggi
    554
    per Ephestus

    Premesso che purtroppo non conosco Javascript
    stavo cercando di modificare pure io questo bello script dunque a me basterebbe che sparisse per sempre l'ora i minuti e i secondi, ho provato ad utilizzare (copia incolla) il codice che hai postato ma non mi funziona, potresti darci una occhiata?

    Un pò di tentativi li avevo fatti pure io togliendo tutti i +document.cal.time.value ma poi mi dava dei problemi sul controllo del formato, oppure quando cercavo di passare da un mese all'altro.

    Se il tuo funziona perfettamente linka o allega il file .js
    Vivrò una vita intera e fortunatamente morirò una volta sola

  6. #6
    Utente di HTML.it L'avatar di pyotrex
    Registrato dal
    Feb 2003
    Messaggi
    554
    Risolto!
    In qualche punto c'era scritto Java script al posto di javascript e un caporiga indigesto.

    Adesso provo a ripristinare come spaziatore - al posto di /
    Vivrò una vita intera e fortunatamente morirò una volta sola

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 © 2025 vBulletin Solutions, Inc. All rights reserved.