SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Date format changes when importing from excel using JavaScript

    Hi, I'm new to JavaScript. I'm trying to import a date value from an Excel workbook using this code.

    Code:
    <html>
    <body>
    <script language=javascript>
    function opnexl()
    {
    var str=document.demoform.link.value;
    var str1=str.replace(/\\/g,"/");
    var Excl = new ActiveXObject("Excel.Application");
    var wrkbk = Excl.workbooks.open(str1);
    var wrksheet = wrkbk.worksheets(1);
    document.demoform.me.value=wrksheet.Range("A1").value;
    Excl.quit();
    }
    </script>
    <form action='<?php echo($_SERVER["PHP_SELF"]) ?>' method='post' name="demoform">
    <div id="divOutput">
    file:<input type=text name=link id=lnk>
    Date:<input type=text name=me onFocus="opnexl()">
    </div>
    </form>
    </body>
    </html>
    Everything works great but the only problem is even though the date value is stored in this format in the excel sheet

    2008-08-15 00:00:00

    it changes to this format after javascript retreives it.

    Fri Aug 15 00:00:00 EDT 2008.

    Why is it so? and how can I get the date in the format stored in the excel sheet?

    Thanks for any help you can give.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Paul Wilkins


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
  •