Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2002
    Posts
    364

    need javascript for today's date +2days

    hi, i need a javascript for:

    show date 2 days in advance

    example today is 27 ..than it would display as 29/12/2004 in dd/mm/yy

    I have tried out someways..but when today date is 31/12/2004 +2 days would be 33/12/2004 which is not correct.. anyone has a working codes for me?

  2. #2
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,104
    I'll write out the difficult part -- you can fill in the rest
    PHP Code:
    <script type="text/javascript">
    /* Year 2000 bug -- for backwards compatibility */

    function y2k(number) {
      return (
    number 1000) ? number 1900 number;
    }

    function 
    getNextDate(number)
    {

      var 
    today     = new Date(); 
      var 
    thisDay   today.getDate();
      var 
    thisMonth today.getMonth();
      var 
    Year  y2k(today.getYear());

      
    /* Days in months */
      
    var days =
        new array(
    312831303130313130313031);
     
      
    /* Check if we are in a leap year */
      
    if (((Year == 0) && (Year 100 != 0)) || (Year 400 == 0))
          
    days[1] = 29
      else
          
    days[1] = 28;

       if (
    thisDay number days[thisMonth 1])
       {
             
    /* The new date will put us in the next month */
       
    } else {
            
    /* The new date is within the current month */
       
    }
    }
    </script> 

  3. #3
    Join Date
    Aug 2002
    Posts
    364
    erm so wat else do i have to do to complete it.. i am not quite good but thanks for ur help anyway..any1 can help me with the rest

  4. #4
    Join Date
    Aug 2002
    Posts
    364
    any1 can help me pls thanks a lot

  5. #5
    Join Date
    Aug 2002
    Posts
    364
    i am kinda stuck can anyone help me with this pls

Posting Permissions

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