SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Today's Date

  1. #1
    Non-Member
    Join Date
    Aug 2007
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Today's Date

    Hey,

    Using JavaScript, how do I display today's date in the following format?:

    00/00/0000

    TicTac

  2. #2
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Matt Alexander
    Alexander Site Design

  3. #3
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u can use this


    Code:
    function get_date()
    {
    var date=new Date();
    
    var year=date.getFullYear();
    
    var month=date.getMonth();
    
    date=date.getDate();
    
    if(date<10) date="0"+date;
    
    month++;
    
    if(month<10) month="0"+month;
    
    date=date+"/"+month+"/"+year;
    
    //document.write(date);
    // or
    
    // return date;
    
    }

  4. #4
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean mm/dd/yyyy or dd/mm/yyyy ?

  5. #5
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mine is dd/mm/yyyy

    he can change it to mm/dd/yyyy by just changing it to

    Code:
    date=month+"/"+date+"/"+year
    Last edited by rohitchawla; Sep 1, 2007 at 04:10.


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
  •