www.webdeveloper.com
Results 1 to 15 of 16

Thread: Help with Showing Dates in Html Pages

Threaded View

  1. #16
    Join Date
    Sep 2007
    Location
    istanbul
    Posts
    315
    <span id="fiveDaysLater">


    var parantez= document.getElementById('fiveDaysLater');


    if ( (( day + i )%7 ) == 6 ) { n= 7; break; }
    if ( (( day + i )%7 ) == 0 ) { n= 6; break; }

    or

    if ( (( day + i )%7 ) == 6 ) { n= n + 2; break; }
    if ( (( day + i )%7 ) == 0 ) { n= n + 1; break; }



    Code:
      
    <span class="renkli">Order within 11am today<br>
    [ <span id="today"></span> ] <br>
            </span><span class="renkli">and receive your delivery on <br>
    [ <span id="fiveDaysLater"></span> ]</span><script type="text/javascript">
        // http://www.webdeveloper.com/forum/showthread.php?277859-Help-with-Showing-Dates-in-Html-Pages
    
        // http://www.w3schools.com/js/js_obj_date.asp
    
        // http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_date_weekday
       
        function format ( num ){
        return ( num < 10) ? '0'+num  : num ; 
        }
    
        var d = new Date();
    
        var el= document.getElementById('today');
        el.innerHTML = format( d.getDate() ) + " / "+ format( d.getMonth() +1 ) + " / "+ d.getFullYear();
    
        var i, n=5,  day= d.getDay();
    
        for(i=1; i<=5 ; i++) {
    
         if ( (( day + i )%7 ) == 6  ) { n= 7; break;  }
         if ( (( day + i )%7 ) == 0  ) { n= 6; break;  }
        
        }
    
        var tarih = new Date(d.setDate(d.getDate() + n));
    
        var parantez= document.getElementById('fiveDaysLater');
    
        parantez.innerHTML = format( tarih.getDate() ) + " / "+ format( tarih.getMonth() +1 ) +" / "+ tarih.getFullYear();
    
                </script>




    TWO DAYS LATER

    var i, n=2, day= d.getDay();

    for(i=1; i<=2 ; i++) {

    if ( (( day + i )%7 ) == 6 ) { n= 4; break; }
    if ( (( day + i )%7 ) == 0 ) { n= 3; break; }



    or

    var i, n=2, day= d.getDay();

    for(i=1; i<=2 ; i++) {

    if ( (( day + i )%7 ) == 6 ) { n= n + 2 ; break; }
    if ( (( day + i )%7 ) == 0 ) { n= n + 1; break; }



    <span id="twoDaysLater">


    var parantez= document.getElementById('twoDaysLater');
    Code:
      
    <span class="renkli">Order within 11am today<br>
    [ <span id="today"></span> ] <br>
            </span><span class="renkli">and receive your delivery on <br>
    [ <span id="twoDaysLater"></span> ]</span>
            <script type="text/javascript">
        // http://www.webdeveloper.com/forum/showthread.php?277859-Help-with-Showing-Dates-in-Html-Pages
    
        // http://www.w3schools.com/js/js_obj_date.asp
    
        // http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_date_weekday
       
        function format ( num ){
        return ( num < 10) ? '0'+num  : num ; 
        }
    
        var d = new Date();
    
        var el= document.getElementById('today');
        el.innerHTML = format( d.getDate() ) + " / "+ format( d.getMonth() +1 ) + " / "+ d.getFullYear();
    
        var i, n=2,  day= d.getDay();
    
        for(i=1; i<=2 ; i++) {
    
         if ( (( day + i )%7 ) == 6  ) { n= n + 2 ; break;  }
         if ( (( day + i )%7 ) == 0  ) { n= n + 1; break;  }
        
        }
    
        var tarih = new Date(d.setDate(d.getDate() + n));
    
        var parantez= document.getElementById('twoDaysLater');
    
        parantez.innerHTML = format( tarih.getDate() ) + " / "+ format( tarih.getMonth() +1 ) +" / "+ tarih.getFullYear();
    
                </script>

    Code:
      
    <span class="renkli">Order within 11am today<br>
    [ <span id="today"></span> ] <br>
            </span><span class="renkli">and receive your delivery on <br>
    [ <span id="twoDaysLater"></span> ]</span>
            <script type="text/javascript">
        // http://www.webdeveloper.com/forum/showthread.php?277859-Help-with-Showing-Dates-in-Html-Pages
    
        // http://www.w3schools.com/js/js_obj_date.asp
    
        // http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_date_weekday
       
        function format ( num ){
        return ( num < 10) ? '0'+num  : num ; 
        }
    
        var d = new Date();
    
        var el= document.getElementById('today');
        el.innerHTML = format( d.getDate() ) + " / "+ format( d.getMonth() +1 ) + " / "+ d.getFullYear();
    
        var i, n=2,  day= d.getDay();
    
        for(i=1; i<=2 ; i++) {
    
         if ( (( day + i )%7 ) == 6  ) { n= 4; break;  }
         if ( (( day + i )%7 ) == 0  ) { n= 3; break;  }
        
        }
    
        var tarih = new Date(d.setDate(d.getDate() + n));
    
        var parantez= document.getElementById('twoDaysLater');
    
        parantez.innerHTML = format( tarih.getDate() ) + " / "+ format( tarih.getMonth() +1 ) +" / "+ tarih.getFullYear();
    
                </script>
    Last edited by Ayşe; 05-28-2013 at 12:05 PM.
    Bismillahirrahmanirrahîm
    Hamd, Âlemlerin Rabbi, Rahmân, Rahîm, hesap ve ceza gününün (ahiret gününün) maliki Allah'a mahsustur. (Allahım!) Yalnız sana ibadet ederiz ve yalnız senden yardım dileriz. Bizi doğru yola, kendilerine nimet verdiklerinin yoluna ilet; gazaba uğrayanların ve sapıklarınkine değil.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles