Web Analytics Made Easy -
StatCounter Oracle timestamp date conversion to Javascript - CodingForum

Announcement

Collapse
No announcement yet.

Oracle timestamp date conversion to Javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Oracle timestamp date conversion to Javascript

    Hi peers,,

    i am passing oracle time stamp dates to javascript array element.
    the problem is i am unable to convert them to standard format :

    here is the date format i am getting from Oracle to javascript array :

    {ts '2011-03-15 00:00:00'}

    and here is what i want to get : 03/15/2011


    Any help ?

    thanks

  • #2
    Ummm...standard JavaScript form for creating a Date is this:
    Code:
    var mydate = new Date( 2011, 3, 15 );
    No place in JavaScript would you ordinarily want to pass in "03/15/2011". It works in some browsers in some circumstances, but it's not the best idea.

    You don't say what server-side technology you are using (PHP? ASP? JSP?) but whichever one it is, the best thing to do is to use coding to convert the Oracle date (however it appears in the server-side language) into the form above.
    Be yourself. No one else is as qualified.

    Comment


    • #3
      Hi OIld PEdant ,

      I am using Coldfusion serv Side language .

      but what i am dong for soem reason is the following :

      i am loading oracle field data into javascript array

      then assign the javascript element date value to form filed values ..

      That is why i van not do it at form field level ..

      thoughts ?

      thanks

      Comment


      • #4
        So you *want* it to appear in the HTML page as something like
        Code:
        <input name="startDate" value="03/15/2011" />
        ??

        In that case, yes, just dump it into the JS array as
        Code:
        var dates = [ "03/15/2011", "05/22/2011", "11/02/2011" ];
        or whatever. CF should give you a way to do that.

        But if it doesn't, if the only thing you can figure out how to do is create
        Code:
        var dates = ['2011-03-15 00:00:00', '2011-05-22 00:00:00', '2011-11-02 00:00:00'];
        then it would be easy enough to ask JS to convert those to mm/dd/yyyy for you.

        example:
        Code:
        var temp = dates[0].replace(/\s/g,"-").split("-");
        var mmddyyyy = temp[1] + "/" + temp[2] + "/" + temp[0];
        document.formName.startDate.value = mmddyyyy;
        But I'd really try to figure out how to get CF to do that for you. It can't be that hard.
        Be yourself. No one else is as qualified.

        Comment


        • #5
          Hi Old PEdant,


          Cf can do it using the DAteFormat(myDate, "mm/dd/yyyy") but for some reasons it did not work..

          thanks

          Comment


          • #6
            As a *guess*, I'd say maybe CF isn't recognizing the value it is getting from Oracle as a valid Date to begin with, so then it can't format what it doesn't think is a date.

            Pure guess.
            Be yourself. No one else is as qualified.

            Comment


            • #7
              Hi Old PEdenat ,

              i have fixed it ..than kyou for redirecting me..there wa a mising " cotation

              thanks gain and sorry for bothering ?

              Comment

              Working...
              X
              😀
              🥰
              🤢
              😎
              😡
              👍
              👎